question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error in creating WebSocket connection

See original GitHub issue

Hello! I am getting an error in generating a WebSocket connection, specifically:

Uncaught DOMException: Failed to construct 'WebSocket': The URL 'undefined' is invalid.

I’ve done a little source-diving, and it appears to be a mismatch between the output to SubscriptionClient of subscriptions-transport-ws and the input to WebSocketLink from apollo-link. It seems that SubscriptionClient has a url property, but WebSocketLink is looking for uri:

https://github.com/apollographql/subscriptions-transport-ws/blob/0da748556bc24ec972dd27afc840e6d63b661b2e/src/client.ts#L112

https://github.com/apollographql/apollo-link/blob/f2124e60dc3720226fd4a88402435fa96835221d/packages/apollo-link-ws/src/webSocketLink.ts#L13

https://github.com/apollographql/apollo-link/blob/f2124e60dc3720226fd4a88402435fa96835221d/packages/apollo-link-ws/src/webSocketLink.ts#L42

Does this seem like a bug, or am I missing something else here?


This issue pertains to the following package(s):

  • GraphQL Playground - Electron App
  • GraphQL Playground HTML
  • GraphQL Playground
  • GraphQL Playground Express Middleware
  • GraphQL Playground Hapi Middleware
  • GraphQL Playground Koa Middleware
  • GraphQL Playground Lambda Middleware

What OS and OS version are you experiencing the issue(s) on?

macOS High Sierra

What version of graphql-playground(-electron/-middleware) are you experiencing the issue(s) on?

v1.5.7

What is the expected behavior?

No errors in WebSocket connection.

What is the actual behavior?

Error in creating a WebSocket connection.

screen shot 2018-03-20 at 11 54 47 am

What steps may we take to reproduce the behavior?

Unknown yet.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:6
  • Comments:9

github_iconTop GitHub Comments

3reactions
adrian-bakercommented, Dec 12, 2018

I’m not creating the link in my own code though, I’m just using the <Playground/> component.

I seem to have been able to avoid the problem, based on the hint in this comment, I’ve added to package.json:

  "resolutions": {
    "subscriptions-transport-ws": "0.9.14",
    "apollo-link-ws": "1.0.8",
    "graphql": "14.0.2"
  }
3reactions
nelsonBlackcommented, Jul 21, 2018

experiencing same problem as @eliperelman , was a fix done ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebSocket: error event - Web APIs | MDN
The error event is fired when a connection with a WebSocket has been closed due to an error (some data couldn't be sent...
Read more >
WebSockets - Handling Errors
WebSockets - Handling Errors, Once a connection has been established between the client and the server, an open event is fired from the...
Read more >
How to resolve the error: "Could not open websocket connection
For the AWS ELB's Classic Load Balancer: The problem will be due to Classic Load Balancer's HTTP protocol not passing along WebSocket requests....
Read more >
Error in creating WebSocket connection · Issue #600 - GitHub
Hello! I am getting an error in generating a WebSocket connection, specifically: Uncaught DOMException: Failed to construct 'WebSocket': The URL ...
Read more >
WebSocket connection failed: Error during ... - Stack Overflow
I just realized that websockets is working partially. I see a 101 Switching Protocols request in the Chrome developer console. However the only ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found