<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hello,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">After struggling with libwebsocket library for some days I switched to using the noPoll<o:p></o:p></p>
<p class="MsoNormal">library. So far things are going really well except I faced one issue very early on:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I am using the library to make a client connection to a websocket server.<o:p></o:p></p>
<p class="MsoNormal">After connecting to a websocket server, the connection is rejected. I see the following error<o:p></o:p></p>
<p class="MsoNormal">after enabling debug log.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">(proc 23267): (critical) nopoll_conn.c:1858 (nopoll_conn_check_mime_header_repeated)
<o:p></o:p></p>
<p class="MsoNormal">Provided header Sec-WebSocket-Protocol twice, closing connection<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The code is using the API somewhat like this:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">noPollConn * connection = nopoll_conn_new(m_pContext, "127.0.0.1", "8080", NULL,<o:p></o:p></p>
<p class="MsoNormal"> "/", "some-protocol", "some-origin");<o:p></o:p></p>
<p class="MsoNormal">
<o:p></o:p></p>
<p class="MsoNormal">Note that we are setting the "protocols" parameter. It seems the server responds with the<o:p></o:p></p>
<p class="MsoNormal">same protocol string set in the header for Sec-WebSocket-Protocol<o:p></o:p></p>
<p class="MsoNormal">but the library rejects this for some reason and closes the connection.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I am not sure if I am doing something wrong in how the library is used<o:p></o:p></p>
<p class="MsoNormal">or there is some other problem. Please advise.<o:p></o:p></p>
<p class="MsoNormal">According to the specification the client can send a list of supported protocols<o:p></o:p></p>
<p class="MsoNormal">and the server can respond with a subset. In our case we only need to use one protocol.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Anyway, after modifying the library (see below) I was able to make progress<o:p></o:p></p>
<p class="MsoNormal">with our implementation and have not seen any other issue yet.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">To 'fix' the above issue I had to comment out two lines at line 2192 in nopoll_conn.c:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">#if 0<o:p></o:p></p>
<p class="MsoNormal"> if (nopoll_conn_check_mime_header_repeated (conn, header, value, "Sec-WebSocket-Protocol", conn->protocols))<o:p></o:p></p>
<p class="MsoNormal"> return 0;<o:p></o:p></p>
<p class="MsoNormal">#endif<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Also I had to later fix an associated memory leak:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">else if (strcasecmp (header, "Sec-Websocket-Protocol") == 0) {<o:p></o:p></p>
<p class="MsoNormal"> nopoll_free (conn->protocols);<o:p></o:p></p>
<p class="MsoNormal"> conn->protocols = value;<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This may not be the correct fix but allowed me to proceed with the rest of<o:p></o:p></p>
<p class="MsoNormal">the implementation.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Rahul<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Rahul Kale<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">IP Video Systems<o:p></o:p></p>
<p class="MsoNormal">Barco, Inc<o:p></o:p></p>
<p class="MsoNormal">1287 Anvilwood Ave<o:p></o:p></p>
<p class="MsoNormal">Sunnyvale, CA 94089<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Tel +1 408 400 4238<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
This message is subject to the following terms and conditions: <a href="http://www.barco.com/en/maildisclaimer">
MAIL DISCLAIMER</a>
</body>
</html>