[Libwebsockets] Denying a Connection

Mooki Moo mookimoo73 at gmail.com
Sat Apr 14 12:39:33 CEST 2018


That was quick, thank you.

I appreciate and unserstand the pupae / butterfly analogy,  but due to
the fact that I know I can expect multiple clients from the same IP
(NAT) from my understanding of the documentation the
LWS_WITH_PEER_LIMITS approach will not work for me. So I need a
solution that will allow multiple connections from the same IP but
only allow one from a distinct user.

As I see it I have a couple of options; the first is to drop the
existing connection, and allow the new one to proceed. Or mark the
request to be dropped then drop it via the LWS_CALLBACK_ESTABLISHED
reason.

Either way I should be able to inform the user via the
lws_close_reason as I already have a connection for scenario A I can
provide a reason as to why the connection was dropped, and the same
for scenario B as the connection will have metamorphosed in to a wss
connection at the LWS_CALLBACK_ESTABLISHED point.

Does this make sense?
-- 
Bill

On 14 April 2018 at 11:10, Andy Green <andy at warmcat.com> wrote:
>
>
> On 04/14/2018 06:01 PM, Mooki Moo wrote:
>>
>> I am using the LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION reason to
>> determine if a user’s connection request can continue. As part of this
>> process I check to see if they are logged elsewhere and if this is the
>> case I deny them.
>
>
> LWS_WITH_PEER_LIMITS might be interesting then.
>
>> However, regardless of my setting the lws_close_reason with an
>> appropriate message (that I wanted to display in my Web UI) the JS
>> 'debug" code tell me I always get a 1006 error code with no reason
>> text.
>>
>> Can someone tell me the most elegant way I can do this please, so that
>> I can propagate a message back to the user, to explain why they cannot
>> connect.
>
>
> ... every ws connection starts as an http connection.
>
> You are denying it - hanging up on it - before it actually upgraded into a
> ws connection.
>
> So the browser doesn't know what to tell you... its ws connection attempt
> became a pupa that did not become as ws butterfly that can tell it why it
> wants to close using ws semantics.
>
> -Andy
>
>>>> Bill
>> _______________________________________________
>> Libwebsockets mailing list
>> Libwebsockets at ml.libwebsockets.org
>> https://libwebsockets.org/mailman/listinfo/libwebsockets
>>
>



More information about the Libwebsockets mailing list