Skip to content
This repository

Issue with test_synchronous when interacting with cowboy master port of sockjs-erlang #57

yrashk opened this Issue October 25, 2012 · 6 comments

3 participants

Yurii Rashkovskii Marek Loïc Hoguin
Yurii Rashkovskii


I've ported sockjs-erlang to cowboy master ( Everything seems to be fine, but I comparing to the master sockjs (that uses much older cowboy) there is one failure:

$ ./venv/bin/python
ERROR: test_synchronous (__main__.Http10)
Traceback (most recent call last):
  File "", line 1449, in test_synchronous
    print c.closed()
  File "/Users/yrashk/tmp/sockjs-protocol/", line 245, in closed
    r = self.s.recv(1) == ''
timeout: timed out

I investigated this issue and I can't think of anything but to blame the test suite :). Here's why:

It fails here, I figured out that what happens here is that connection variable is an empty string (I was printing out values)

However, when I run curl I get this:

* Connected to localhost ( port 8081 (#0)
> GET /echo HTTP/1.1
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:8081
> Accept: */*
< HTTP/1.1 200 OK
< connection: keep-alive
< server: Cowboy
< date: Thu, 25 Oct 2012 21:10:09 GMT
< content-length: 19
< Content-Type: text/plain; charset=UTF-8
Welcome to SockJS!

As you can see, it has connection: keep-alive header. When I modify the test-suite to force it in believing it got connection: keep-alive the test passes without a problem.

Any ideas why this might be happening?


Correct me if I'm wrong, but you're saying that: When tests send a HTTP/1.0 request, with 'Connection: keep-alive' header set, cowboy responds with no 'Connection' header and 'Content-Length' set correctly. Furthermore, when test suite receives that (ie: lack of Connection header) it assumes that the server speaks correct HTTP/1.0 and expects the tcp/ip connection to be closed by the server. But that never happens.

Curl uses HTTP/1.1.

@essen What do you think? Is that possible? I believe that if server doesn't respond with 'Connection: keep-alive', it's correct to assume that it will use HTTP/1.0 semantics - ie: close connection after response.

Yurii Rashkovskii

Not sure, I'm not able to take a closer look now. Let's wait for what @essen says!

Loïc Hoguin

HTTP/1.0 doesn't have keep-alive, it will always close the connection.
HTTP/1.1 will use keep-alive if there is no connection header or if the value is unspecified.

It makes no sense to check for a connection header when using HTTP/1.0. Even if you do reply a connection header, if it's HTTP/1.0 the header should be discarded and the connection should be closed.

I'm not sure this is what Cowboy is doing, but at least this is what it should do. :)

Marek majek referenced this issue in sockjs/sockjs-erlang October 30, 2012

Add Cowboy 0.6.1 support #37


Right, looks like a minor bug on cowboy side.


@yrashk Feel free to reopen this issue if you think there is something more to it then the cowboy http 1.0 thing.

Marek majek closed this November 09, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.