title: SignalR server closes connection to Unity client right after SSE connection is established
body: <p>I'm working on a prototype project connecting a self-hosted SignalR server running on Mono with C# clients (for testing) and Unity clients (representing the actual use-case scenario). The Unity client is using <a href="https://www.assetstore.unity3d.com/en/#!/content/10872" rel="nofollow noreferrer">BestHTTP Pro</a> as its SignalR library.</p>
  
  <p>As the WebSocket transport method is not supported on Mono, I'm focusing on server-sent events, and observing very odd behavior there. Communication between server and C# clients is working just fine out of the box. With the Unity client though, the (supposedly) persistent connection is closed immediately after the initial response to the <code>/signalr/connect</code> request. No errors are reported anywhere; the response code is 200 in both cases.</p>
  
  <p>Further investigation with <a href="http://www.telerik.com/fiddler" rel="nofollow noreferrer">Fiddler</a> reveals that the Unity client is sending a <code>Connection: Keep-Alive</code> header that the C# client <em>doesn't</em> send, to which the server responds with a <code>Connection: close</code> header and, well, closing the connection (in other words, exactly the opposite of what the client asks it to do).</p>
  
  <p>Manually removing the keep-alive request header actually makes everything work with the Unity client. Since this feels more like an odd workaround than a correct solution, my question is: Is this strange server-side behavior a bug in the SignalR libraries? Or could Mono be to blame here (I suspect this might be the case)? How can I dig deeper into this, and ideally make the SSE transport work without client-side hacks?</p>
  
  <p>Library versions used:</p>
  
  <ul>
  <li><a href="https://www.nuget.org/packages/Microsoft.AspNet.SignalR" rel="nofollow noreferrer">Microsoft ASP.NET SignalR 2.2.1</a></li>
  <li><a href="https://www.assetstore.unity3d.com/en/#!/content/10872" rel="nofollow noreferrer">BestHTTP Pro 1.9.17</a></li>
  </ul>
  
  <p>For reference, here are the full request/response headers; Unity/BestHTTP client:</p>
  
  <pre><code>GET /signalr/connect?tid=1&amp;_=XXX&amp;transport=serverSentEvents&amp;clientProtocol=1.5&amp;connectionToken=XXX&amp;connectionData=XXX HTTP/1.1
  Accept: text/event-stream
  Cache-Control: no-cache
  Accept-Encoding: identity
  Host: XXX
  Connection: Keep-Alive
  Connection: Keep-Alive, TE
  TE: identity
  User-Agent: BestHTTP
  
  HTTP/1.1 200 OK
  X-Content-Type-Options: nosniff
  Content-Type: text/event-stream
  Server: Mono-HTTPAPI/1.0
  Date: Wed, 08 Mar 2017 10:34:05 GMT
  Connection: close
  Content-Length: 73
  </code></pre>
  
  <p>C# client:</p>
  
  <pre><code>GET /signalr/connect?clientProtocol=1.4&amp;transport=serverSentEvents&amp;connectionData=XXX&amp;connectionToken=XXX HTTP/1.1
  User-Agent: SignalR.Client.NET45/2.2.1.0 (Microsoft Windows NT 6.2.9200.0)
  Accept: text/event-stream
  Host: XXX
  
  HTTP/1.1 200 OK
  X-Content-Type-Options: nosniff
  Content-Type: text/event-stream
  Server: Mono-HTTPAPI/1.0
  Date: Wed, 08 Mar 2017 13:11:16 GMT
  Transfer-Encoding: chunked
  Keep-Alive: timeout=15,max=99
  </code></pre>