[noPoll] Issue with using "protocols" field from the client

Kale, Rahul Rahul.Kale en barco.com
Mar Mayo 26 21:07:40 CEST 2015


Hello,

After struggling with libwebsocket library for some days I switched to using the noPoll
library. So far things are going really well except I faced one issue very early on:

I am using the library to make a client connection to a websocket server.
After connecting to a websocket server, the connection is rejected. I see the following error
after enabling debug log.

(proc 23267): (critical) nopoll_conn.c:1858 (nopoll_conn_check_mime_header_repeated)
Provided header Sec-WebSocket-Protocol twice, closing connection

The code is using the API somewhat like this:

noPollConn * connection  = nopoll_conn_new(m_pContext, "127.0.0.1", "8080", NULL,
                "/", "some-protocol", "some-origin");

Note that we are setting the "protocols" parameter. It seems the server responds with the
same protocol string set in the header for Sec-WebSocket-Protocol
but the library rejects this for some reason and closes the connection.

I am not sure if I am doing something wrong in how the library is used
or there is some other problem. Please advise.
According to the specification the client can send a list of supported protocols
and the server can respond with a subset. In our case we only need to use one protocol.

Anyway, after modifying the library (see below) I was able to make progress
with our implementation and have not seen any other issue yet.

To 'fix' the above issue I had to comment out two lines at line 2192 in nopoll_conn.c:

#if 0
        if (nopoll_conn_check_mime_header_repeated (conn, header, value, "Sec-WebSocket-Protocol", conn->protocols))
                return 0;
#endif

Also I had to later fix an associated memory leak:

else if (strcasecmp (header, "Sec-Websocket-Protocol") == 0) {
        nopoll_free (conn->protocols);
        conn->protocols = value;
}

This may not be the correct fix but allowed me to proceed with the rest of
the implementation.

Thanks,

Rahul

Rahul Kale

IP Video Systems
Barco, Inc
1287 Anvilwood Ave
Sunnyvale, CA  94089

Tel  +1 408 400 4238

This message is subject to the following terms and conditions: MAIL DISCLAIMER<http://www.barco.com/en/maildisclaimer>
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://lists.aspl.es/pipermail/nopoll/attachments/20150526/efd8659a/attachment-0001.html>


Más información sobre la lista de distribución noPoll