question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support different client and server ports

See original GitHub issue

This is related to https://github.com/lydell/elm-watch/issues/39 which solved my problem for SSL hand off being done by an external server (An nginx Ingress in Kubernetes in this case).

I was able to have elm-watch listening on port 443 (but serving HTTP not HTTPS) as this port was not being used by anything else as the nginx was running elsewhere.

However, in another use case I have, I am running everything on my laptop - I use a local haproxy to do the SSL handoff. This of course must listen on port 443 thus not allowing elm-watch to also listen on this port.

Therefore I would really like to be able to configure the elm-watch client port to be 443 but set the server port to something else. In haproxy I would then rewrite /elm-watch to the server port.

I know that you are not keen on extra configuration options, so perhaps this could be done via an environment variable either to change the client port or the server port?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
chazsconicommented, Nov 7, 2022

For now, you can use a hack like this:

<script>
window.WebSocket = class HackWebSocket extends WebSocket {
  constructor(urlParam) {
    const url = new URL(urlParam);
    if (looksLikeElmWatch(url)) {
      url.port = "1234";
    }
    super(url);
  }
}

function looksLikeElmWatch(url) {
  return url.port === "4321";
  // or return url.pathname === "/elm-watch";
}
</script>

This works great - thanks for the tip!

Ok, one more question: If I were to add cert configuration to elm-watch.json, would it look something like this for you then?

{
  "sslCertificate": {
    "cert": "./ssl/le-certs/foo.crt",
    "key": "./ssl/le-certs/foo.key"
  },
  "targets": {}
}

Yes, this would be perfect.

So far, I’ve only found HAProxy that concatenates them. And even in that case, couldn’t you “just” keep three files on disk?

In fact HAProxy doesn’t concatenate them - it just expects all the files in the same folder.

0reactions
chazsconicommented, Dec 27, 2022

Just some extra info for anyone else using a setup with HAProxy: To prevent elm-watch from frequently reloading, you will need to add something like this to your HAProxy config in the backend section for elm-watch

timeout tunnel 1h
Read more comments on GitHub >

github_iconTop Results From Across the Web

Server Ports Versus Client Ports - Get Certified Get Ahead
Ports are logical numbers used by TCP/IP to identify what service or application should handle data received by a system.
Read more >
Different Ports on Server and Client? - Super User
One thing you're missing is that TCP connections use two ports, one on each side. The "source" port is usually assigned randomly, ...
Read more >
Configure client communication ports - Configuration Manager
Configure ports for a site ... Switch to the Ports tab. ... Select a service, and then select the Properties icon to open...
Read more >
Do client and server need to use same port to connect?
I have a Server-Client program using java, I tried to create a ServerSocket with a port and Client Socket with different port and...
Read more >
Ports - IBM
In the client/server model, the server provides a resource by listening for clients on a particular port. Some applications, such as FTP, SMTP,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found