Closed boy-jer closed 10 years ago
I'm not sure what nitrous is using to proxy the server, it may not support websockets. Can you check with them? HijackNotAvailable means you probably aren't running puma, so check that nitrous is running your app w/ puma too.
-Nick
Thanks Nick for the response and for writing the gem. I go working and I don't know what I changed. As I just kept trying different things that came to my head.
For the url passed to websocket, this is the one that worked, and before it failed so obviously I changed something else that made it work. That something is what I can't immediately place my hand on:
socket = new WebSocket("ws://" + window.location.host + "/chat/chat");
Thanks again.
[1]. Ooops before I close it, I just want to ask if the controller action used for calling hijack do |tubesock|* can be a create action, so we make a post request instead of get. All the examples I have seen use a get request.
class ChatController < ApplicationController
include Tubesock::Hijack
def create
hijack do |tubesock|
tubesock.onopen do
tubesock.send_data "Hello, friend"
end
end
end
end
Is such usage appropriate.
[2]. Secondly supposed I have a ChatController with its model and another SupportTicketsController and its model, can I add * include Tubesock::Hijack* and create a new \ hijack do |tubesock|. I am asking because I tried this and I am now getting No data received* even for the ChatController* that previously worked.
Thanks
I think WS requests must be gets. I dunno. I am not sure what situation that would make sense in.
Tubesock should work in multiple controllers. I don't know what the problem is.
ok thanks.
I just tried the chat demo application with tubesock (0.2.2), Rails 4.1.0.beta1, jubilee (1.1.0-java), JRuby 1.7.9. Got similar errors:
In Chrome console:
WebSocket connection to 'ws://10.10.22.116:3000/chat' failed: Error during WebSocket handshake: Unexpected response code: 500
In Rails log:
Started GET "/chat" for 10.10.23.94 at 2014-01-24 10:58:25 -0800
Processing by ChatController#chat as HTML
Completed 500 Internal Server Error in 7ms
Tubesock::HijackNotAvailable (Tubesock::HijackNotAvailable):
app/controllers/chat_controller.rb:5:in `chat'
Note that Rails treated the request as HTML. Is this the normal way?
@ngauthier Could you please reopen this issue? Or should I create a new one? Thanks.
Hi @nengxu. What web server are you using to serve the app? It must support Rack Hijack for Tubesock Hijack to work.
The only one I've had consistent results with is Puma. Are you using puma from jruby? I also haven't tried Tubesock on JRuby.
As mentioned above, I'm using Jubilee, not Puma.
I just tried Puma (2.7.1) on JRuby, it worked. However, whenever I enter something in the input field, all clients will receive the 'something' twice. I will open a new issue for this.
Thanks.
OK. It's probably a difference in threading between mri and jruby, but we can check it out in a separate issue. Also, using jubilee should be a separate issue too :-)
Thanks!
Confirmed that Jubilee did not support hijack yet:
https://github.com/isaiah/jubilee/issues/4#issuecomment-33410647
That solves that! :D
On Mon, Jan 27, 2014 at 2:23 PM, nengxu notifications@github.com wrote:
Confirmed that Jubilee did not support hijack yet:
isaiah/jubilee#4 (comment)https://github.com/isaiah/jubilee/issues/4#issuecomment-33410647
— Reply to this email directly or view it on GitHubhttps://github.com/ngauthier/tubesock/issues/18#issuecomment-33410756 .
Just following your simple chat example. And when I naviage to my index page or to localhost:3000/chat, I get this error in the console:
please note that since I use nitous.io, my localhost is app-dev-32586.euw1.actionbox.io
When I submit a form, it throws in chrome console:
my gemfile:
My route:
This is my controller
The js file and the erb file are exactly same as this in your example:
I also change the url passed to websocket to point to "/chat/chat" but it changed nothing.
In the rails console, when I do:
The stack trace:
Any suggestions. Thanks