Skip to content
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

[Access] Enable Event streaming on REST API #4547

Conversation

UlyanaAndrukhiv
Copy link
Contributor

@UlyanaAndrukhiv UlyanaAndrukhiv commented Jul 7, 2023

#4379

This pull request:

  • added a new route type wsroute with SubscribeEvents and its handler implementation to existing REST router,
  • added new WSHandler to handle websockets requests,
  • refactored REST Handler by moving common logic to HttpHandler,
  • added unit and integration tests

Copy link
Contributor

@peterargue peterargue left a comment

Choose a reason for hiding this comment

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

overall this approach looks good. I added a few comments, but didn't review thoroughly since this is still a work in progress.

cmd/access/node_builder/access_node_builder.go Outdated Show resolved Hide resolved
engine/common/state_stream/backend.go Outdated Show resolved Hide resolved
engine/common/state_stream/subscribe_handler.go Outdated Show resolved Hide resolved
integration/localnet/builder/bootstrap.go Outdated Show resolved Hide resolved
integration/localnet/builder/bootstrap.go Outdated Show resolved Hide resolved
engine/access/rest/router.go Outdated Show resolved Hide resolved
engine/access/rest/request/event_type.go Outdated Show resolved Hide resolved
@UlyanaAndrukhiv UlyanaAndrukhiv changed the title [WIP] [WIP] [Access] Enable Event streaming on REST API Jul 19, 2023
@UlyanaAndrukhiv UlyanaAndrukhiv changed the title [WIP] [Access] Enable Event streaming on REST API [Access] Enable Event streaming on REST API Aug 3, 2023
Copy link
Contributor

@peterargue peterargue left a comment

Choose a reason for hiding this comment

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

thanks for the updates! Added a few more, mostly nits and testing requests.

I tried to test this out using localnet and this curl command:

curl -vvv --include \
     --no-buffer \
     --header "Connection: Upgrade" \
     --header "Upgrade: websocket" \
     --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
     --header "Sec-WebSocket-Version: 13" \
     http://localhost:4004/v1/subscribe_events

it seems to timeout after a few seconds. I modified the code a bit to return errors from the read handler, and it returned

�>�read tcp 192.168.80.10:8070->192.168.80.1:37030: i/o timeout* Connection #0 to host localhost left intact

I suspect this is from the pong handler config.

engine/access/rest/routes/router.go Outdated Show resolved Hide resolved
engine/access/rest/routes/router.go Outdated Show resolved Hide resolved
engine/access/rest/routes/websocket_handler.go Outdated Show resolved Hide resolved
engine/access/rest/routes/websocket_handler.go Outdated Show resolved Hide resolved
engine/access/rest/routes/websocket_handler.go Outdated Show resolved Hide resolved
engine/access/rest/routes/subscribe_events_test.go Outdated Show resolved Hide resolved
engine/access/rest/routes/subscribe_events_test.go Outdated Show resolved Hide resolved
engine/access/rest/routes/subscribe_events_test.go Outdated Show resolved Hide resolved
@UlyanaAndrukhiv
Copy link
Contributor Author

thanks for the updates! Added a few more, mostly nits and testing requests.

I tried to test this out using localnet and this curl command:

curl -vvv --include \
     --no-buffer \
     --header "Connection: Upgrade" \
     --header "Upgrade: websocket" \
     --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
     --header "Sec-WebSocket-Version: 13" \
     http://localhost:4004/v1/subscribe_events

it seems to timeout after a few seconds. I modified the code a bit to return errors from the read handler, and it returned

�>�read tcp 192.168.80.10:8070->192.168.80.1:37030: i/o timeout* Connection #0 to host localhost left intact

I suspect this is from the pong handler config.

Thank you for all your comments!

The timeout issue you encountered related to the WebSocket ping-pong mechanism. Curl is not well-suited for WebSocket testing as it does not handle WebSocket ping-pong processes. I tried using curl with the Gorilla WebSocket 'chat' example and received the same Connection #0 to host localhost left intact message.

I recommend wscat tool, which I have been using to test event streaming on localnet.

Copy link
Member

@durkmurder durkmurder left a comment

Choose a reason for hiding this comment

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

Looks good from my side, good job.

Copy link
Contributor

@peterargue peterargue left a comment

Choose a reason for hiding this comment

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

Looking good. I think this is ready after these last few comments.

engine/access/rest/routes/router.go Outdated Show resolved Hide resolved
engine/access/rest/routes/websocket_handler.go Outdated Show resolved Hide resolved
engine/access/rest/routes/websocket_handler.go Outdated Show resolved Hide resolved
Copy link
Contributor

@peterargue peterargue left a comment

Choose a reason for hiding this comment

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

looks good. Great work @UlyanaAndrukhiv!

@durkmurder durkmurder added this pull request to the merge queue Sep 15, 2023
Merged via the queue into onflow:master with commit 37c79a3 Sep 15, 2023
36 checks passed
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.

4 participants