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

Can a HTTP Server and WebSocket Server share the same Port #25

Open
konvasil opened this issue Apr 23, 2024 · 2 comments
Open

Can a HTTP Server and WebSocket Server share the same Port #25

konvasil opened this issue Apr 23, 2024 · 2 comments

Comments

@konvasil
Copy link

konvasil commented Apr 23, 2024

Is this something that can be done, and increase efficiency or better to have to different ports for each? I am asking this here because when I am pressing my button that is bind with osc message sent function it sends the message after 3 clicks approximatelly, so I am wondering if this is because the websocket server uses a different port number.

@colinbdclark
Copy link
Owner

I think it's typical that they do, yes. That's how the osc.js browser example works. I'm not sure, though, that the port(s) used is the cause of the issue you're facing. But it sounds like some strategic logging and/or use of a debugger will help track it down.

@konvasil
Copy link
Author

Interesting, thanks for the link. I tried to modify the server part according to your example, but now it throws this error:

A Web Socket connection has been established!
/Users/k.vasilakos/Dev/ltt/node_modules/osc/src/osc.js:101
            throw new Error("Can't wrap a non-array-like object as Uint8Array. Object was: " +
                  ^

Error: Can't wrap a non-array-like object as Uint8Array. Object was: "�l�-�y"
    at osc.byteArray (/Users/k.vasilakos/Dev/ltt/node_modules/osc/src/osc.js:101:19)
    at p.decodeOSC (/Users/k.vasilakos/Dev/ltt/node_modules/osc/src/osc-transports.js:79:20)
    at osc.WebSocketPort.emit (node:events:519:28)
    at socket.onmessage (/Users/k.vasilakos/Dev/ltt/node_modules/osc/src/platforms/osc-websocket-client.js:58:18)
    at callListener (/Users/k.vasilakos/Dev/ltt/node_modules/ws/lib/event-target.js:290:14)
    at WebSocket.onMessage (/Users/k.vasilakos/Dev/ltt/node_modules/ws/lib/event-target.js:209:9)
    at WebSocket.emit (node:events:519:28)
    at Receiver.receiverOnMessage (/Users/k.vasilakos/Dev/ltt/node_modules/ws/lib/websocket.js:1209:20)
    at Receiver.emit (node:events:519:28)
    at /Users/k.vasilakos/Dev/ltt/node_modules/ws/lib/receiver.js:608:16

Node.js v21.7.3

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