[Libwebsockets] Multiple local clients connecting to local server

Mattia Romeo mromeo at giganticmechanic.com
Thu Jun 11 18:34:12 CEST 2015


Thank you! That was it. I would have been banging my head against that for ages. This seems like a bug in the library and if not it should at least be documented (especially since all the examples use a static protocols array). I don’t see an issue on Github about this. Is that because I’m wrong about it being issue-worthy or just because no one’s gotten around to reporting it yet?
On June 10, 2015 at 8:02:23 PM, Bruce Perens (andy.green at linaro.org) 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 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


_______________________________________________  
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/20150611/ba62b872/attachment-0001.html>


More information about the Libwebsockets mailing list