-
-
Notifications
You must be signed in to change notification settings - Fork 161
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
Proxy WebSocket connections #447
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Miguel Álvarez <[email protected]>
Hi @GiviMAD just wanted to let you know I plan on reviewing this soon, possible this weekend. Thanks! |
Signed-off-by: Miguel Álvarez <[email protected]>
Thank you @digitaldan I was to write you the other day but I saw the message a little late. Hope everything is in place. I have added a small change in the last commit using "process.nextTick" to write the pending socket data, because I think it will behave a little better when handling multiple clients. |
* Write to socket handling backpressure | ||
*/ | ||
function writeToSocket(stream, data) { | ||
const pending = stream[PendingWrites] = (stream[PendingWrites] || []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, funny, i have never come across using the Symbol
type before. Is the point of this to avoid creating custom named variables on the local stream
object ? So to avoid using a variable name as a unique key ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It allows to create non enumerable properties on an object (meaning it will not be returned by Object.entries and other ways to list the object keys) and unlike a custom property name it can't collision with other part of the code, because event if you create other symbol with same name is not considered to be the same symbol.
I can't remember when I learnt about it but I always found it very useful.
Hello, these is a proposed PR to allow proxy WebSocket connections to the OpenHAB instances, to the endpoints exposed under path /ws/.
With the PR, the code catches the upgraded response headers and setup the required listeners on the request Socket in order to transfer the incoming data through the Socket.IO connection to the destination server using the "websocket" event. Also handles the "websocket" events from the remote server and write the received data to the socket.
I have also changed the responses like
res.send(200, '...');
to beres.status(200).send('...');
because I saw deprecation warnings when running the project using docker-compose.These PR needs changes in the Cloud Connector add-on.