[Libwebsockets] Internet versus LAN connections

Willem Burgers wa.burgers+lws at gmail.com
Tue Aug 12 13:37:01 CEST 2014

Hi Andy,

Thanks for your help.
While trying different things, I finally got it to work.
It indeed had nothing to do with the library, but the port number was
apparently causing issues.
Weird that it was still working over LAN though.
I feel a bit stupid now...

Thanks again and keep up the good work.
The library rocks!


2014-08-12 0:49 GMT+02:00 Andy Green <andy at warmcat.com>:

> On 12 August 2014 00:15:13 GMT+08:00, Willem Burgers <
> wa.burgers+lws at gmail.com> wrote:
> >Hi,
> >
> >I have a libwebsockets server running.
> >Whenever I try to connect over LAN, it works perfectly fine, but when I
> >try
> >to connect over the Internet, the connection times out with error code
> >1006.
> >I have forwarded the websocket port on my router to the correct port
> >for
> >the server.
> >In the JavaScript of the page I use the external IP obviously.
> >I tried a NodeJS echo server, which works fine over the Internet.
> >Also the libwebsockets-test-server works perfectly fine.
> Well, if the test server can work, there should be no problem on the
> library side.
> >My HTTP callback just returns 0, because the html file is hosted on
> >another
> >machine.
> >
> >static int httpCallback(struct libwebsocket_context *context,
> >struct libwebsocket *wsi,
> >enum libwebsocket_callback_reasons reason,
> > void *user, void *in, size_t len) {
> >    return 0;
> >}
> >
> >Should this be changed for libwebsockets to work over the Internet?
> No although I never tried it, it should be ok.
> >Does it need to accept the Upgrade http request itself?
> Yes lws must get the upgrade request.  Otherwise is neither knows you want
> a websocket connection nor what protocol etc
> >If so, why does it work over LAN connections?
> I suspect you're confusing the general http serving support done by the
> user callback, with the handling of the upgrade request, which is done by
> the library itself since it is required for any websocket connection.  If
> so it's a red herring.
> What I would do is 1) tcpdump the handshake from both sides and if that
> doesn't help, 2) replace my user code with user code from the test server.
>  If that works, change it back to your code piece by piece until it breaks
> again.
> -Andy
> >Thanks,
> >Willem
> >
> >
> >------------------------------------------------------------------------
> >
> >_______________________________________________
> >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/20140812/63fab17a/attachment-0001.html>

More information about the Libwebsockets mailing list