[Libwebsockets] Mulit server unusual behaviour with lws

Andy Green andy at warmcat.com
Thu Aug 10 10:19:27 CEST 2017



On August 10, 2017 3:43:27 PM GMT+08:00, Vijay Khurdiya <vijay.khurdiya at gmail.com> wrote:
>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.

I am not sure what you are trying to ask.  But it sounds like you have a wrong idea and are wondering why the world doesn't conform to your wrong idea.

Some stuff cannot be known until it is either parsed or negotiated.  If you are asking 'why doesn't everything know what happens in the future from the start', that'd be a stupid question, right?

If I miss the point and something for lws to improve, happy to consider your patches.

-Andy

>
>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
>>



More information about the Libwebsockets mailing list