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

Websock connection closing abnormally when running inside docker container #43

Open
maheshkulkarni4 opened this issue Aug 10, 2022 · 0 comments

Comments

@maheshkulkarni4
Copy link

I am trying to run the graphqlws inside a docker container. The code is straight forward and if I test locally it works fine. My UI App is able to establish a Websocket connection and receive messages coming from Server.

But when I run inside docker, the path to reach my server is as follows.
Browser -> UI POD (https) -> nginx -> proxy to graphql/Server pod

I have already added the following headers in my Nginx to allow proper traffic

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "keep-alive, upgrade";
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
proxy_pass http://graphql;

But still, the following error is thrown immediately

time="2022-08-10T10:40:05Z" level=info msg="Created connection" prefix="graphqlws/connection/d2751293-304b-448c-8e44-0c97f108feec"                                                  ││ time="2022-08-10T10:40:49Z" level=warning msg="Closing connection" prefix="graphqlws/connection/d2751293-304b-448c-8e44-0c97f108feec" reason="websocket: close 1006 (abnormal closu ││ time="2022-08-10T10:41:19Z" level=info msg="Remove subscriptions" conn=d2751293-304b-448c-8e44-0c97f108feec prefix="graphqlws/subscriptions"                                        ││ time="2022-08-10T10:41:21Z" level=info msg="Closed connection" prefix="graphqlws/connection/d2751293-304b-448c-8e44-0c97f108feec"           
  • UI is accessing this with wss:// and nginx routes to http:// as its pod to pod traffic
  • I tried to Run the Server Application locally and able to access the endpoint on ws:// locally, it works perfectly fine.
  • I tried to port-forward the server pod and use connection with ws:// it did not work either. Same error as above is thrown.

Below is the handler implementation

func (g *Handle) NewSubscriptionHandler(kubeconfig, apiHost string, loginHandler login.Handler) http.Handler {
	return graphqlws.NewHandler(graphqlws.HandlerConfig{
		SubscriptionManager: subscription.Manager(),
		Authenticate: func(token string) (interface{}, error) {
                            // Auth code, removed for obvious purpose
		},
	})
}

Could you please advise how to handle or fix this issue ?

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

No branches or pull requests

1 participant