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

feature request: add option for non-http(s) ws #452

Closed
sionzee opened this issue Jun 24, 2020 · 5 comments
Closed

feature request: add option for non-http(s) ws #452

sionzee opened this issue Jun 24, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@sionzee
Copy link

sionzee commented Jun 24, 2020

If user won't visit the vite server then the HMR is not loaded. Atm people could use hostname:24678 for HMR but that was changed at 7fe66cc . Right now people will get error message: hmr:44 WebSocket connection to 'ws://hostname:3000/' failed: Error during WebSocket handshake: Unexpected response code: 200. Cuz vite server has not send upgrade event due not visiting the server location exposed by vite server. They are also stuck in infinite loop where each refresh calls [vite] server connection lost. polling for restart... again.

Can we have option to use WS not based on host location but on specific port like it was before 7fe66cc?


I'm using vite from RoR to pack typescripts and support HMR. So vite is behaving like side server for bundling. That is why vite is running on different port than main application.

@yyx990803
Copy link
Member

Tbh the description is far from clear and even if I vaguely understand what you mean, I need to see an actual setup to really figure out what to do.

@sionzee
Copy link
Author

sionzee commented Jun 24, 2020

I tried to replicate it on nodejs but it shows the issue only partially: [ REPO ] (the part with infinity loop is not there)

  • install the packages
  • run npm start
  • run npm run vite

visit localhost:3000 and you won't see [vite] connecting... nor 'connected...' in console.

When you visit localhost:9000 then it works as is expected.

This can be easily fixed by adding ability to run ws on custom port.
If you downgrade version to Vite 4, you can notice it will be again working without any issues.


In my case insteadof NodeJS I'm using RoR in a huge project. It is not easily editable like NodeJS is.

@yyx990803
Copy link
Member

yyx990803 commented Jul 2, 2020

I don't think this should be a supported use case. Vite needs to rewrite the HTML you are serving to ensure correct behavior.

@yyx990803 yyx990803 reopened this Jul 2, 2020
underfin pushed a commit to rolldown/vite that referenced this issue Jul 4, 2020
Allows assets to be served under a different port
close vitejs#452, close vitejs#460
@DazDotOne
Copy link

Just on the off-chance anybody comes across this thread as I did. This is my first time using vite (vith Vue).

I was trying to get my project set up with Docker and was getting this error resulting in what looked like HMR being triggered.

It seems to happen when mapping two different ports in docker-compose.yml.

I was mapping like this (port 8080 has been set in vite.config.js and running in the docker container):

ports:
      - "8081:8080"

changing to 8080:8080 fixed it for me.

@github-actions
Copy link

This issue has been locked since it has been closed for more than 14 days.

If you have found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Vite version. If you have any other comments you should join the chat at Vite Land or create a new discussion.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants