[Libwebsockets] Mulit server unusual behaviour with lws

Vijay Khurdiya vijay.khurdiya at gmail.com
Thu Aug 10 09:43:27 CEST 2017


Thanks for quick reply.

You have rightly pointed about uses of http call back,i have used & i can
see http call accordingly coming to http callback handler.
Usually have one host name or one set of server certificate.In that case
what is possibility of getting callback received accordingly while vhost
creation.


On Thu, Aug 10, 2017 at 12:03 PM, Andy Green <andy at warmcat.com> wrote:

>
>
> On August 10, 2017 2:18:00 PM GMT+08:00, Vijay Khurdiya <
> vijay.khurdiya at gmail.com> wrote:
> >Hi all,
> >
> >I have just started getting my head with LWS,it work perfectly with
> >single
> >server but with two server i was getting some unusual behavior.
> >
> >I have created both server (Server 1 first & Server 2 second) with
> >explicit
> >vhost & running on same port (443) but different network interface. (Ex
> >:
> >eth0,wlan0)
>
> It should support this fine.
>
> >Example protocol used as mentioned below.
> >static struct lws_protocols protocols_server1[] = {
> >{
> >"dumb-increment-protocol",
> >callback_dumb_increment_server1,
> >sizeof(struct per_session_data__dumb_increment),
> >10,
> >},
> >{ NULL, NULL, 0, 0 } /* terminator */
> >}
> >
> >static struct lws_protocols protocols_server2[] = {
> >{
> >"dumb-increment-protocol",
> >callback_dumb_increment_server2,
> >sizeof(struct per_session_data__dumb_increment),
> >10,
> >},
> >{ NULL, NULL, 0, 0 } /* terminator */
> >}
> >
> >I found all the way on or after client connected callback coming for
> >server
> >2 on server 1 callback however I found WSI create callback coming on
> >right
> >server callback.
>
> I think you are maybe a bit confused by the fact protocols[0] is used when
> there is no known protocol.
>
> That includes server wsi creation... at that time the http headers are not
> parsed so there is no ws protocol defined for the wsi.
>
> When it does not yet know which vhost, it uses the first vhost on the same
> port.  Later it will correct the wsi via SNI or Host: header to figure out
> which vhost.  Then it's important your vhost .name field reflects the
> hostname clients use to reach that vhost.
>
> It's further confused because you didn't provide a 'http only' protocol
> for protocols[0].  You can use lws_callback_http_dummy() exported in
> libwebsockets.h to make a fake one.
>
> -Andy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20170810/05b035b7/attachment-0002.html>


More information about the Libwebsockets mailing list