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

url of created websocket is just 'ws://' despite of passed url #310

Open
bondom opened this issue Nov 11, 2020 · 1 comment
Open

url of created websocket is just 'ws://' despite of passed url #310

bondom opened this issue Nov 11, 2020 · 1 comment

Comments

@bondom
Copy link

bondom commented Nov 11, 2020

I pass next url to create websocket client and server: ws://localhost/abs/abs.
When checking created websocket instance I see that webSocket.url equals just ws://.

This problem is really annoying when you have 2 websocket instances: even if we pass 2 different urls to WebSocket constructor, both of them will be equal to ws://, as a result if I add message event listener using addEventListener to websocket, that was created first, when 2nd websocket is created, this message event listener will be called never.

I managed to fix bug with websocket client/server url when I commented out urlParse code and just store passed url into this.url on Client and Server classes, so insead of

class Server extends EventTarget {
  constructor(url, options = {}) {
    super();
    const urlRecord = new URL(url);

    if (!urlRecord.pathname) {
      urlRecord.pathname = '/';
    }

    this.url = urlRecord.toString();

I use:

class Server extends EventTarget {
  constructor(url, options = {}) {
    super();
    this.url = url;

(The same for Client class)

@bondom bondom changed the title url of created websocket is just 'ws://' url of created websocket is just 'ws://' despite of passed url Nov 11, 2020
@Atrue
Copy link
Collaborator

Atrue commented Sep 28, 2021

Is it still reproducible?

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

2 participants