Skip to content

WebSocket proxy for the grpc-gateway#752

Merged
hariso merged 23 commits intomainfrom
haris/grpc-gateway-websockets
Jan 2, 2023
Merged

WebSocket proxy for the grpc-gateway#752
hariso merged 23 commits intomainfrom
haris/grpc-gateway-websockets

Conversation

@hariso
Copy link
Contributor

@hariso hariso commented Nov 28, 2022

Description

This PR extracts from https://github.com/tmc/grpc-websocket-proxy/ the most important parts of code to us. This library has been introduced as a dependency in #718.

Update: gorilla/websocket got archived: https://github.com/gorilla#gorilla-toolkit

Quick checks:

  • I have followed the Code Guidelines.
  • There is no other pull request for the same update/change.
  • I have written unit tests.
  • I have made sure that the PR is of reasonable size and can be easily reviewed.

@hariso hariso changed the base branch from main to haris/stream-inspector-destination November 28, 2022 11:46
Base automatically changed from haris/stream-inspector-destination to main November 30, 2022 13:29
commit 541cd83
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Tue Nov 29 14:32:49 2022 +0100

    simplify tests

commit 6737ab4
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Tue Nov 29 13:57:14 2022 +0100

    cosmetics

commit 9dbc8b1
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Tue Nov 29 13:36:32 2022 +0100

    rename

commit f218ed2
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Tue Nov 29 13:18:46 2022 +0100

    tests

commit b7f2baf
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Tue Nov 29 11:40:25 2022 +0100

    simplify

commit fd699c1
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Mon Nov 28 13:02:55 2022 +0100

    improvements

commit 27bf6ec
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Mon Nov 28 12:47:54 2022 +0100

    rename method

commit 7ec409d
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Mon Nov 28 12:09:34 2022 +0100

    linter

commit 3593282
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Mon Nov 28 12:02:16 2022 +0100

    init copy

commit 52ffbc7
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Tue Nov 22 20:24:40 2022 +0100

    setup

commit 623ca25
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Tue Nov 22 12:10:43 2022 +0100

    pr feedback 3

commit 83c6152
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Tue Nov 22 11:34:29 2022 +0100

    Revert "Update pkg/web/api/connector_v1_test.go"

    This reverts commit 8f40c22.

commit 6df36fc
Merge: dd8b1b4 8f40c22
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Tue Nov 22 11:29:21 2022 +0100

    Merge branch 'haris/stream-inspector-destination' of github.com:ConduitIO/conduit into haris/stream-inspector-destination

commit dd8b1b4
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Tue Nov 22 11:28:27 2022 +0100

    linter

commit 7865b60
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Tue Nov 22 11:26:07 2022 +0100

    pr feedback 2

commit 8f40c22
Author: Haris Osmanagić <haris@meroxa.io>
Date:   Tue Nov 22 11:18:58 2022 +0100

    Update pkg/web/api/connector_v1_test.go

    Co-authored-by: Lovro Mažgon <lovro.mazgon@gmail.com>

commit 5067241
Author: Haris Osmanagić <haris@meroxa.io>
Date:   Tue Nov 22 11:08:57 2022 +0100

    Update pkg/inspector/inspector_test.go

    Co-authored-by: Lovro Mažgon <lovro.mazgon@gmail.com>

commit e7b3306
Author: Haris Osmanagić <haris@meroxa.io>
Date:   Tue Nov 22 11:08:17 2022 +0100

    Update pkg/inspector/inspector_test.go

    Co-authored-by: Lovro Mažgon <lovro.mazgon@gmail.com>

commit 3a0b31b
Author: Haris Osmanagić <haris@meroxa.io>
Date:   Tue Nov 22 10:58:40 2022 +0100

    Update pkg/inspector/inspector_test.go

    Co-authored-by: Lovro Mažgon <lovro.mazgon@gmail.com>

commit 1a94458
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Mon Nov 21 14:06:27 2022 +0100

    linter

commit ae1408f
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Mon Nov 21 14:05:46 2022 +0100

    linter

commit 1848a05
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Mon Nov 21 14:05:01 2022 +0100

    Stream inspector for destinations
@hariso hariso force-pushed the haris/grpc-gateway-websockets branch from 541cd83 to 7cd3254 Compare November 30, 2022 13:38
@hariso hariso marked this pull request as ready for review November 30, 2022 14:31
@hariso hariso requested a review from a team as a code owner November 30, 2022 14:31
Copy link
Contributor

@lovromazgon lovromazgon left a comment

Choose a reason for hiding this comment

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

Seems like we will still need a read loop to figure out when the client closed the connection so we can cancel our context (this and this). Right now Conduit won't stop even if the client stops the inspector session because it thinks the connection is still open.

@hariso
Copy link
Contributor Author

hariso commented Dec 19, 2022

Seems like we will still need a read loop to figure out when the client closed the connection so we can cancel our context (this and this). Right now Conduit won't stop even if the client stops the inspector session because it thinks the connection is still open.

Can you tell me a bit more about how you tested it? I tested this a few times in the following way:

  1. Start Conduit with a pipeline
  2. Inspect a session with wscat. Wait for some records.
  3. Kill wscat
  4. Stop Conduit with Ctrl-+C or kill -SIGINT

This worked. There's an issue with shutting down with an open inspector session though (#747).

@lovromazgon
Copy link
Contributor

Here are steps to reproduce what I mean:

  1. Terminal 1: ./conduit -pipelines.path=examples/pipelines (provisions the example pipeline)
  2. Terminal 2: wscat -c ws://localhost:8080/v1/connectors/file-to-file:example.out/inspect
  3. Terminal 3: echo "hi" >> example.in (see the record appear in the inspector and in example.out)
  4. Terminal 2: Ctrl+C (kill wscat)
  5. Terminal 1: Ctrl+C (kill Conduit)

Conduit then doesn't shut down, also the message session removed is never logged.

Note that you can reproduce the same thing by simply navigating to http://localhost:8080/ui/pipelines/file-to-file, since the UI opens an inspector session. Even after closing the tab Conduit thinks the session is still open.

@hariso
Copy link
Contributor Author

hariso commented Dec 19, 2022

@lovromazgon Thanks for that! I used the same steps, but after I tried it out a few times I realized it takes a bit of time for the context to be closed and the session to be removed. In other words, if you perform steps 4 and 5, you'll get to the behavior you described. But if there's a short pause, then it's all good. Thanks for noticing this, I'll look into what's causing it.

commit 5dad631
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Thu Dec 22 13:34:34 2022 +0100

    linter

commit 3c9fef2
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Thu Dec 22 13:07:45 2022 +0100

    ctx check

commit 7368327
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Thu Dec 22 11:55:49 2022 +0100

    ping pongs working

commit 088852f
Author: Haris Osmanagic <haris@meroxa.io>
Date:   Wed Dec 21 14:55:49 2022 +0100

    Revert "remove ping-pong"

    This reverts commit b584fcf.
Copy link
Contributor

@lovromazgon lovromazgon left a comment

Choose a reason for hiding this comment

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

Nice, good work!

hariso and others added 2 commits December 23, 2022 20:15
Co-authored-by: Lovro Mažgon <lovro.mazgon@gmail.com>
Co-authored-by: Lovro Mažgon <lovro.mazgon@gmail.com>
@hariso hariso enabled auto-merge (squash) January 2, 2023 11:11
@hariso hariso merged commit d13761f into main Jan 2, 2023
@hariso hariso deleted the haris/grpc-gateway-websockets branch January 2, 2023 11:11
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.

2 participants