Comments (27)
Hate to resurface this, but I just realized that this issue actually still shows up for me but only on Firefox. It works completely fine on Chrome though.
I tested it out with your it with your example project as well.
from puma-dev.
I'm getting the exact same error as @glennfu above on latest Firefox.
I have a Rails running on a port, if I access it as localhost
it works, else it fails upgrading the socket.
# *.dev
Started GET "/cable" for 127.0.0.1 at 2017-02-21 17:42:55 -0500
Started GET "/cable/"[non-WebSocket] for 127.0.0.1 at 2017-02-21 17:42:55 -0500
Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: , HTTP_UPGRADE: )
Finished "/cable/"[non-WebSocket] for 127.0.0.1 at 2017-02-21 17:42:55 -0500
# localhost:3000
Started GET "/cable" for ::1 at 2017-02-21 17:43:00 -0500
Started GET "/cable/" [WebSocket] for ::1 at 2017-02-21 17:43:00 -0500
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: keep-alive, Upgrade, HTTP_UPGRADE: websocket)
from puma-dev.
Is it me or does puma-dev mangle Connection and Upgrade headers?
from puma-dev.
Seems like I was able to find the root cause of this issue. Basically Firefox sends Connection: keep-alive, Upgrade
, which isn't parsed correctly by puma-dev since it assumes it should be just Upgrade
for a websocket request. #143 fixes that by checking that the value ends with Upgrade
. Feel free to give it a spin and let me know if it helps
from puma-dev.
I can confirm that I'm unable to get websockets to work properly when accessing an app served by puma-dev with Firefox, but it works with Chrome.
When I access the same app with a simple rails s
with Firefox, the websockets connect just fine.
Started GET "/cable" for 127.0.0.1 at 2017-10-30 11:48:40 -0600
Started GET "/cable/"[non-WebSocket] for 127.0.0.1 at 2017-10-30 11:48:40 -0600
Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: , HTTP_UPGRADE: )
How can I help troubleshoot this issue?
from puma-dev.
@glennfu Lot's of questions:
- Did you mount ActionCable at
/cable
in your routes? - What about if you set
config.action_cable.disable_request_forgery_protection = true
? - Did you change
app/assets/javascripts/channels/index.coffee
to haveApp.cable = ActionCable.createConsumer("/cable")
? - Try not setting
web_socket_server_url
at all. Also, I see it being calledaction_cable.url
.
from puma-dev.
- Yes - This setup already works in Production, and works if I call
rails s
in a separate iTerm window and pointconfig.web_socket_server_url
to the IP of that running instance. - I tried that, no apparent change.
- I tried changing
ActionCable.createConsumer()
toActionCable.createConsumer("/cable")
but there's no change in the logs/errors - Not setting
web_socket_server_url
didn't seem to change anything either. The logs all still reference "/cable" as I guess this is the default. I think you're right thataction_cable.url
is the new preferred way to set but since "/cable" is already the default, setting it here isn't changing anything for my setup.
Also In the FireBug console I see this:
Firefox can’t establish a connection to the server at ws://stinkergame.dev/cable.
this.webSocket = new WebSocket(this.consumer.url, protocols);
The connection to ws://stinkergame.dev/cable was interrupted while the page was loading.
this.webSocket = new WebSocket(this.consumer.url, protocols);
from puma-dev.
Check if spring
has left a rails process running in the background and kill it if so. I had this problem at one point where configuration wasn't taking because of that.
from puma-dev.
Here is the sample app that I used to test websockets: https://github.com/puma/actioncable-examples
from puma-dev.
I don't believe I've been using spring, but just in case, I ran spring stop
. I normally restart the server with touch tmp/restart.txt && tail -f log/development.log
from puma-dev.
I was having issues with the new release as well but I had to do a puma-dev --uninstall then brew uninstall, after that I reinstalled it thru brew and it started working. A simple brew upgrade did not take effect the new changes, even after a system restart as well.
from puma-dev.
@navied Yes, that's true and I realize now that's going to be causing a problem. @glennfu can you please do puma-dev -uninstall
, then puma-dev -install
and try websockets again?
from puma-dev.
OK I did the following:
puma-dev -uninstall
brew install puma/puma/puma-dev
touch tmp/restart.txt && tail -f log/development.log
No perceived difference. Then I restarted my laptop and tried again. Now I'm actually getting a difference. Unfortunately it's still not working. Now the Firebug log looks like:
"NetworkError: 404 Not Found - http://mygame.dev/cable"
Firefox can’t establish a connection to the server at ws://mygame.dev/cable.
this.webSocket = new WebSocket(this.consumer.url, protocols);
and in Rails log:
Started GET "/cable" for 127.0.0.1 at 2016-08-09 11:05:59 -0500
Started GET "/cable/"[non-WebSocket] for 127.0.0.1 at 2016-08-09 11:05:59 -0500
Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: , HTTP_UPGRADE: )
Finished "/cable/"[non-WebSocket] for 127.0.0.1 at 2016-08-09 11:05:59 -0500
These both spam together in unison frequently. Under puma-dev 0.7, I'd only get 1 Rails log request, and tons of Firebug spam about "interrupted".
Here's the puma-dev.log:
→ tail -f ~/Library/Logs/puma-dev.log
→ tail -f ~/Library/Logs/puma-dev.log
mygame[1700]: stty: stdin isn't a terminal
mygame[1700]: stty: stdin isn't a terminal
mygame[1700]: RVM loading: /Users/Glenn/.rvm/environments/ruby-2.3.0
mygame[1700]: Puma starting in single mode...
mygame[1700]: * Version 3.0.2 (ruby 2.3.0-p0), codename: Plethora of Penguin Pinatas
mygame[1700]: * Min threads: 0, max threads: 5
mygame[1700]: * Environment: development
mygame[1700]: * Listening on unix:/Users/Glenn/.puma-dev/mygame/tmp/puma-dev-330.sock
mygame[1700]: Use Ctrl-C to stop
! App 'mygame' booted
from puma-dev.
Just for some extra context, skipping puma-dev I can do rails s
and change config.action_cable.url
to "ws://localhost:3000/cable"
Then in the Rails log I see:
Started GET "/cable" for ::1 at 2016-08-09 11:13:36 -0500
Started GET "/cable/" [WebSocket] for ::1 at 2016-08-09 11:13:36 -0500
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: keep-alive, Upgrade, HTTP_UPGRADE: websocket)
from puma-dev.
Just to be sure, can you update puma
to the last version as well? I don't think that will fix it but worth it to try.
Also, you don't list doing puma-dev -install
in your initial steps, I assume you did do that but forgot to list it?
What version of rails? I think I need to try and replicate the issue locally which I'm not able to do right now. Would you be wiling to try the actioncable-examples repo I linked before and see if it works for you?
from puma-dev.
Oh sorry, yeah, here's what I actually did:
puma-dev -uninstall
brew install puma/puma/puma-dev
sudo puma-dev -setup
puma-dev -install
touch tmp/restart.txt && tail -f log/development.log
restart computer
touch tmp/restart.txt && tail -f log/development.log
I'll take a look at actioncable-examples later and see if I can reproduce my situation.
from puma-dev.
OK, I checked out actioncable-examples. It runs ActionCable on a separate server instance, which is not the default setup, and not the situation that I've described here. To get it looking right, I changed development.rb
with:
- config.action_cable.url = 'ws://localhost:28080'
+ config.action_cable.url = "ws://localhost:3000/cable"
+ config.action_cable.allowed_request_origins = ["http://localhost:3000"]
and routes.rb
with:
+ mount ActionCable.server => '/cable'
With this change, rails s
fires up a server accessible at "http://localhost:3000" and I can go there and test that ActionCable works just fine. The server log shows:
Started GET "/cable" for ::1 at 2016-08-10 12:23:04 -0500
Started GET "/cable/" [WebSocket] for ::1 at 2016-08-10 12:23:04 -0500
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: keep-alive, Upgrade, HTTP_UPGRADE: websocket)
Next, to test puma-dev:
I turned off the server, and made these changes to development.rb
:
config.action_cable.url = "ws://actioncable-examples.dev/cable"
config.action_cable.allowed_request_origins = ["http://actioncable-examples.dev"]
Then I setup puma-dev to load the app at actioncable-examples.dev
and started the server with puma-dev.
Visiting http://actioncable-examples.dev I see the same errors as described above:
Firefox can’t establish a connection to the server at ws://actioncable-examples.dev/cable.
Then in the server log:
Started GET "/cable" for 127.0.0.1 at 2016-08-10 12:21:42 -0500
Started GET "/cable/"[non-WebSocket] for 127.0.0.1 at 2016-08-10 12:21:42 -0500
Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: , HTTP_UPGRADE: )
Finished "/cable/"[non-WebSocket] for 127.0.0.1 at 2016-08-10 12:21:42 -0500
EDIT: I also noticed the puma version was "2.15.3". I ran bundle update puma
to get it to "3.6.0", but it didn't seem to change anything.
from puma-dev.
The puma fork is what you want to test. It changes the config to run all in
one server with /cable mounted. Please try it as is under puma-dev and let
me know if it works for you (it does for me)
On Wed, Aug 10, 2016 at 11:24 AM Glenn Sidney [email protected]
wrote:
OK, I checked out actioncable-examples. It runs ActionCable on a separate
server instance, which is not the default setup, and not the situation that
I've described here. To get it looking right, I changed development.rb
with:
- config.action_cable.url = 'ws://localhost:28080'
- config.action_cable.url = "ws://localhost:3000/cable"
- config.action_cable.allowed_request_origins = ["http://localhost:3000"]
and routes.rb with:
- mount ActionCable.server => '/cable'
With this change, rails s fires up a server accessible at "
http://localhost:3000" and I can go there and test that ActionCable works
just fine. The server log shows:Started GET "/cable" for ::1 at 2016-08-10 12:23:04 -0500
Started GET "/cable/" [WebSocket] for ::1 at 2016-08-10 12:23:04 -0500
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: keep-alive, Upgrade, HTTP_UPGRADE: websocket)Next, to test puma-dev:
I turned off the server, and made these changes to development.rb:config.action_cable.url = "ws://actioncable-examples.dev/cable"
config.action_cable.allowed_request_origins = ["http://actioncable-examples.dev"]Then I setup puma-dev to load the app at actioncable-examples.dev and
started the server with puma-dev.Visiting http://actioncable-examples.dev I see the same errors as
described above:Firefox can’t establish a connection to the server at ws://actioncable-examples.dev/cable.
Then in the server log:
Started GET "/cable" for 127.0.0.1 at 2016-08-10 12:21:42 -0500
Started GET "/cable/"[non-WebSocket] for 127.0.0.1 at 2016-08-10 12:21:42 -0500
Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: , HTTP_UPGRADE: )
Finished "/cable/"[non-WebSocket] for 127.0.0.1 at 2016-08-10 12:21:42 -0500—
You are receiving this because you commented.Reply to this email directly, view it on GitHub
#48 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAAAB8qRRasjBWGKbF67OWxtKYPWaSAjks5qegkwgaJpZM4JfYnl
.
from puma-dev.
Can you clarify what that means? If I google Puma and "fork" or "puma fork" I can't find any clarity on how to use this or what that means.
from puma-dev.
I mean https://github.com/puma/actioncable-examples. It has commits to work inside puma-dev as a test. I'm in the midst of writing a new actioncable test app as well.
from puma-dev.
OK I see what you mean. I just switched over to using that repo, and added config.action_cable.url = "ws://actioncable-examples.dev/cable"
to it, and I see exactly the same errors.
from puma-dev.
Ok, but why is setting that required? It works correctly without it.
On Fri, Aug 12, 2016 at 2:59 PM Glenn Sidney [email protected]
wrote:
OK I see what you mean. I just switched over to using that repo, and added config.action_cable.url
= "ws://actioncable-examples.dev/cable" to it, and I see exactly the same
errors.—
You are receiving this because you commented.Reply to this email directly, view it on GitHub
#48 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAAAB6ITf36g7WRjXTucYNxRqiszbNOkks5qfN6sgaJpZM4JfYnl
.
from puma-dev.
If I checkout that project and don't make any changes at all, I get the same error. I can't find any configuration that uses a .dev url to host the app through puma-dev that makes ActionCable connect.
from puma-dev.
This issue is killing me for two days, any ideas? It doesn't work with any browser for me and I also tried everything in this thread by now. Here is a SO questioned I also opened about this: https://stackoverflow.com/questions/44602711/actioncable-never-establishes-connection-to-channel
from puma-dev.
I haven' been able to get it to work at all with puma-dev. I kept getting handshake issues and the server wasn't even logging any attempts at a connection 😞
Doing a manual rails server startup and creating a connection to ws://localhost:3000 worked without a hitch.
from puma-dev.
Trying to figure out what to change in the codebase is probably a good start! ;)
from puma-dev.
@joallard Yes, of course. If I knew golang and this project better, there would probably already be a PR. Thanks for the suggestion though ;)
from puma-dev.
Related Issues (20)
- Add a generic command to the proxy support HOT 2
- puma-dev not working in Ubuntu 22.04 with Rails 4 HOT 2
- "unexpected exit: No puma executable found for ruby system" HOT 1
- [zsh] [mac] On Mac OS puma-dev loads interactive zsh init files HOT 2
- Running in Docker Alpine results in `http: panic serving 172.17.0.1:42896: runtime error: invalid memory address or nil pointer dereference` HOT 1
- How to stop puma-dev without uninstalling?
- puma-dev -install can miss adding CA cert to Keychain HOT 1
- Ruby version mismatch between puma-dev and the Rails app HOT 1
- Allow multiple copies of the same app to run independently with different configurations HOT 2
- Not reaching app HOT 2
- Server's ip address could not be found.
- Instructions for puma-dev HTTPS with guard-livereload?
- How to use while offline? HOT 1
- `DNS Server failed: listen tcp 127.0.0.1:9253: bind: address already in use` error when starting the app with `puma-dev` command HOT 3
- Cannot configure puma-dev to use ipv6 proxy
- Curl::Err::HostResolutionError on WSL HOT 2
- Difference with Linux and MacOS for same code
- Changing the port is not picked up
- Request initiated in one app being responded to from another. HOT 3
- exec: puma: not found HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from puma-dev.