[Libwebsockets] Multiple local clients connecting to local server

Bruce Perens bruce at perens.com
Thu Jun 11 02:02:04 CEST 2015


If you call libwebsocket_create_context more than once, for example to
start a non-SSL and an SSL server for the same application, or to serve
more than one network port separately, you must make sure that there is a
new copy of the struct libwebsocket_protocols array for each call. If you
make the mistake of reusing the same array twice, libwebsockets quietly
uses the wrong file descriptors. Maybe that's what is happening to you.

It took me hours to track this one down.

On Wed, Jun 10, 2015 at 5:01 PM, Bruce Perens <bruce at perens.com> wrote:

> If you call libwebsocket_create_context more than once, for example to
> start a non-SSL and an SSL server for the same application, or to serve
> more than one network port separately, you must make sure that there is a
> new copy of the struct libwebsocket_protocols array for each call. If you
> make the mistake of reusing the same array twice, libwebsockets quietly
> uses the wrong file descriptors. Maybe that's what is happening to you.
>
> It took me hours to track this one down.
>
> On Wed, Jun 10, 2015 at 3:37 PM, Mattia Romeo <andy.green at linaro.org>
> wrote:
>
>> I’m trying to test some C++ server and client wrappers around
>> libwebsockets locally. Everything works fine when connecting a single local
>> client to a single local server. When I try to connect multiple clients I
>> run into an issue: the server receives messages from all connected clients,
>> but any messages sent from the server are always sent to the last connected
>> client. For example, I set up a simple echo server (i.e. all messages sent
>> to server are sent back to the client) and 3 clients. The server receives
>> all the messages from the clients but the third client receives all the
>> server’s responses.
>>
>> I can’t find any issues in my code and I vaguely recall hearing that
>> there can only be one local client connected to a local server, so I
>> thought I would check if this is a known limitation with web sockets, or a
>> known issue with libwebsockets before I start tearing my hair out further.
>>
>> Thanks,
>> Mattia
>>
>>
>> _______________________________________________
>> Libwebsockets mailing list
>> Libwebsockets at ml.libwebsockets.org
>> http://ml.libwebsockets.org/mailman/listinfo/libwebsockets
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20150610/64096d5e/attachment-0001.html>


More information about the Libwebsockets mailing list