Skip to content

Implement enough to make this pass autobahn-testsuite #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 13, 2021

Conversation

rawrafox
Copy link
Contributor

@rawrafox rawrafox commented Jun 7, 2021

This adds features and fixes enough old ones that all tests in https://github.com/crossbario/autobahn-testsuite passes, even if some of them do so non-strictly by either not failing early or by simply not implementing any extensions.

Description

Previously there was a lot of edge-cases related to error handling, framing, and closing connections that was not implemented. I implemented enough new features that you can now run the autobahn-testsuite and it passes with the following echo server.

autobahn-test-results.zip

require "async/websocket/adapters/rack"

class RawConnection < Async::WebSocket::Connection
  def parse(buffer)
    buffer
  end

  def dump(buffer)
    buffer
  end
end

app = lambda do |env|
  response = Async::WebSocket::Adapters::Rack.open(env, handler: RawConnection) do |connection|
    while message = connection.read
      connection.write(message)
    end
  end

  if response
    response
  else
    [406, {}, ["Please use websockets"]]
  end
end

run app

The most important changes is that the framing is fixed in text frames and control frames, we try to implement the closing handshake, and that we check for reserved bits that we don't support yet (because they have not been specified at this moment).

There is a workaround for a bug in Async::IO for 0-length reads in there, it should probably be fixed in Async::IO and then removed from here before this is merged. We should probably also add these tests to CI, but I'm going to call for the local CI-expert @olleolleolle to help with that.

Types of Changes

  • Bug fix.
  • New feature.
  • Maintenance.

Testing

  • I added tests for my changes.
  • I tested my changes locally.
  • I tested my changes in staging.
  • I tested my changes in production.
  • I have run external tests

@rawrafox rawrafox force-pushed the autobahn-test-suite branch 2 times, most recently from 82ae6ca to 7680cbc Compare June 10, 2021 12:56
buffer = @frames.map(&:unpack).join
buffer = @frames.map(&:unpack).join("")

if @frames.first.is_a?(TextFrame)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest something more like:

buffer = @frames.first.decode(buffer)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is something I do not understand here, is there a Frame#decode method?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, I'm suggesting we introduce it. The frame class should know how to process the data.

@rawrafox rawrafox force-pushed the autobahn-test-suite branch from 7680cbc to 5a0f484 Compare June 14, 2021 09:36
@rawrafox rawrafox force-pushed the autobahn-test-suite branch 2 times, most recently from cc8b6d4 to 26224ac Compare July 13, 2021 20:19
Copy link
Contributor

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen it run locally, looks good to me!

@rawrafox rawrafox force-pushed the autobahn-test-suite branch 4 times, most recently from 2b9637a to 78e6861 Compare July 13, 2021 21:39
This adds features and fixes enough old ones that all tests in https://github.com/crossbario/autobahn-testsuite passes, even if some of them do so non-strictly.
@rawrafox rawrafox force-pushed the autobahn-test-suite branch from 78e6861 to 718ab34 Compare July 13, 2021 21:41
@ioquatix ioquatix merged commit 072cac0 into socketry:master Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants