collective-soundworks / soundworks

Creative coding framework for distributed applications based on Web technologies.
http://soundworks.dev
BSD 3-Clause "New" or "Revised" License
114 stars 7 forks source link

Setting websocket port from browser client doesn't work as expected #90

Closed joshstovall closed 6 months ago

joshstovall commented 7 months ago

Is there a reason config.env.port cannot be set from the browser client? After a bit of troubleshooting I was able to get plugin-sync working in my React/Next.js app. In order to have my frontend (port 3000) connect to websocket running on a seperate server (port 8000), I had to change this line in the soundworks source code. It seems right now it sets the port for the outgoing websocket connection based on it's own window.location.

https://github.com/collective-soundworks/soundworks/blob/489f7488946ecbefd294f6155128013e96eadc87/src/client/Socket.js#L107

Not sure if this is done on purpose, but it seems odd to me. Thought I would point it out incase someone runs into the same problem in the future. Looking forward to trying out soundworks more!

b-ma commented 7 months ago

Thank for the feedback

Is there a reason config.env.port cannot be set from the browser client?

Not really except we never had this use case before. I will propose a fix for that

b-ma commented 6 months ago

Fixed in v4.0.0-alpha.22

You can now pass serverAddress and port in ClientConfig.env, it will be used to open the socket connection to server

cf. https://soundworks.dev/soundworks/client.html#.ClientConfig

Let me know if it works for you!