erlanglab / erlangpl

Tool for developers working with systems running on the Erlang VM (BEAM). It helps with performance analysis.
http://www.erlang.pl/
Apache License 2.0
546 stars 40 forks source link

websocket port is hard coded #41

Closed dgulinobw closed 7 years ago

dgulinobw commented 7 years ago

Command line parameter '-P' does not change the web-ui's port to connect to epl's websocket. So if you change the port via '-P', you can connect to the gui with a browser at that port, but no data will be displayed.

The websocket port is hardcoded in web-ui/src/sockets.js:


index ef7b989..c90257f 100644
--- a/src/sockets.js
+++ b/src/sockets.js
@@ -92,7 +92,7 @@ let socketsArray = [];
 export const createSockets = (sockets: any) => {
   socketsArray = Object.keys(sockets).map(route => {
     const { hostname } = window.location;
-    let ws = new WebSocket(`ws://${hostname}:8000/${route}`);
+    let ws = new WebSocket(`ws://${hostname}:9080/${route}`);

     const handlers = Object.keys(sockets[route].topics).reduce(
       (acc, topic) => {```
baransu commented 7 years ago

Thank for spotting this! Good solution would be to create some endpoint providing config for UI and then creating WebSocket connection based on that.

arkgil commented 7 years ago

I think that sufficient solution would be to allow users to enter hostname and port number to connect to from UI (which would defualt to localhost:8000 of course). If someone wants to change port number we serve content on, if think they would be fine configuring it in UI. What would you think about that @dgulinobw?

dgulinobw commented 7 years ago

An automated way would be cool, but anything that doesn't involve rebuilding would be sufficient.

michalslaski commented 7 years ago

In the old UI we injected WebSocket port number read from the command line argument into the HTML/JS templates before serving them from cowboy to browsers. Is the same possible after React is built, e.g. can we regexp on "8000" and change it to custom port number?

baransu commented 7 years ago

Probably yes but it's far from being elegant. And we have also Elm code which can look for port number, we could pass it from React via ports but I don't know. I would go with config endpoint with:

michalslaski commented 7 years ago

@dgulinobw is port 8000 conflicting with some service, which is running on many operating systems?

The original intention behind having -P flag was to allow users, who have port 8000 occupied by other processes in the system, to decide which port is most suitable for their setup. I can see two options:

baransu commented 7 years ago

I would keep -P flag.

No problem with that. So in production when assets are served by server it will look for port in url and for development it will look for default 8000 when UI is standalone.

michalslaski commented 7 years ago

It seems the port 8000 is a default one for many popular applications like WinAmp and trojans. Maybe it makes sense to have the development port set to 37575.

BTW, try typing on the classic phone with T9 the word "erlpl".

baransu commented 7 years ago

So let switch to 37575 by default keeping -P flag.