[Libwebsockets] SegFault for Websocket Server on Multiple Network Interface

techi eth techieth at gmail.com
Tue Jul 18 07:58:17 CEST 2017


Thanks for hint.



After adding explicit vhost option while vhost creation, stuff is working
fine. What all mandatory info we need to set while creating context when
setting up *LWS_SERVER_OPTION_EXPLICIT_VHOSTS**.*



*I found when you are using SSL server you need to set SSL option &
cert,key & ca path to be set.*



*One more input needed :*

*Can we make client connection on different context ?*

On Tue, Jul 18, 2017 at 10:31 AM, Andy Green <andy at warmcat.com> wrote:

>
>
> On 07/18/2017 12:50 PM, techi eth wrote:
>
>> Test Server as it works perfectly. As mentioned earlier for single
>> interface test stuff is working ok but when you have two interface there is
>> problem.
>>
>
> Good.
>
> I don't understand what that ah thing is yet, but for sure you can't just
> call the vhost destroy from inside the service.
>
> I have tried as suggested by you for destroying vhost not in callback but
>> still issue persist. Please find attached modified patch for test server.
>>
>
> I tried your test app, it's too much like your code and not like the test
> app.  For example it doesn't build as patch on lws (due to unused vars and
> other problems).  It needs me to make a ws connection directly using your
> protocol names.
>
> It couldn't work either because LWS_SERVER_OPTION_EXPLICIT_VHOSTS was
> needed to still be set when the vhosts are created.  The test apps all
> reuse the same struct so this was always OK for them.  I pushed a small
> patch that removes that necessity and just has everything follow the
> context option for it, so it only needs setting once now at context
> creation time.
>
> It's quicker for me to redo your test aligned with the test server.
>
> What exactly is the problem coming now?  Still related to ah?
>
> -Andy
>
>
>
>>
>>
>> On Mon, Jul 17, 2017 at 10:54 PM, Andy Green <andy at warmcat.com <mailto:
>> andy at warmcat.com>> wrote:
>>
>>
>>
>>     On 07/17/2017 08:26 PM, techi eth wrote:
>>
>>         Please find attached patch over test_server.Base test server
>>         code work fine with one interface but with two interface i am
>>         seeing problem.
>>         Please check attached patch & point me for issue.I have run
>>         below command to start test server.
>>
>>
>>     It's good to know if the test server works OK for you as-is.
>>
>>     Destroying the vhost during service is probably going to make
>>     trouble, because the caller may hold pointers to it if nothing else.
>>
>>     +               case LWS_CALLBACK_ESTABLISHED :
>>     +                       lws_get_peer_simple(wsi,IPAddrBuf,32);
>>     +                       printf ("fWebsocketWrapServer1CB :
>>     LWS_CALLBACK_ESTABLISHED,Client IP=%s,Socket ID
>>     =%d\n",IPAddrBuf,lws_get_socket_fd(wsi));
>>     +                       printf("Calling LWS VHOST DESTROY\n");
>>     +                       lws_vhost_destroy(vhost1);
>>
>>     Why don't you follow what the test server does and create and
>>     destroy the vhosts outside of the service.
>>
>>     -               if (dynamic_vhost_enable && !dynamic_vhost) {
>>     -                       lwsl_notice("creating dynamic vhost...\n");
>>     -                       dynamic_vhost = lws_create_vhost(context,
>>     &info);
>>     -               } else
>>     -                       if (!dynamic_vhost_enable && dynamic_vhost) {
>>     -                               lwsl_notice("destroying dynamic
>>     vhost...\n");
>>     -                               lws_vhost_destroy(dynamic_vhost);
>>     -                               dynamic_vhost = NULL;
>>     -                       }
>>     +//             if (dynamic_vhost_enable && !dynamic_vhost) {
>>     +//                     lwsl_notice("creating dynamic vhost...\n");
>>     +//                     dynamic_vhost = lws_create_vhost(context,
>>     &info);
>>     +//             } else
>>     +//                     if (!dynamic_vhost_enable && dynamic_vhost) {
>>     +//                             lwsl_notice("destroying dynamic
>>     vhost...\n");
>>     +//                             lws_vhost_destroy(dynamic_vhost);
>>     +//                             dynamic_vhost = NULL;
>>     +//
>>
>>     -Andy
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20170718/f047461d/attachment-0002.html>


More information about the Libwebsockets mailing list