ryanb / private_pub

Handle pub/sub messaging through private channels in Rails using Faye.
MIT License
863 stars 226 forks source link

Publish_to not working #48

Closed ghost closed 12 years ago

ghost commented 12 years ago

I have successfully gotten faye to work alone (pushing messages to both users), but when incorporating private_pub I have been having problems. Now the faye server starts without any errors but it still does not seem to work as expected.

Publish_to doesn't seem to work, when I wrap my append in my create.js.erb, it simply does not work (Doesn't post the message for either user).

<% publish_to "/messages/new" do %> $("#chat").append("<%= escape_javascript render(@message) %>"); <% end %>

When I remove the publish too, it will at least post for the single user. Anyone have any suggestions on how to debug this? I can upload my whole project to github if that would be helpful in diagnosis. I followed every step in the guide and I'm using rails 3.2.

I also tried doing publish_to in the controller and still nothing happened.

ghost commented 12 years ago

curl http://localhost:9292/faye -d 'message={"channel":"/messages/new", "data":"hello", "ext":"secret"}' curl http://localhost:9292/faye -d 'message={"channel":"/messages/new", "data":"hello", "ext":"{'private_pub_token':'secret'}"}'

Both return:

[{"channel":"/messages/new","error":"Incorrect token.","successful":false}]

Note: I'm using the default config under development, I even tried changing the production secret_token to secret. I also tried faye 0.7.1, faye 0.8.0 and faye 0.8.1

mido18 commented 11 years ago

@chemicalfire same here can you tell me what you did ?

randika commented 10 years ago

I get the same error - does anyone here figured this out?

gregmolnar commented 10 years ago

@randika is your application public? If not can you tell me the steps you did before getting the error?

randika commented 10 years ago

@gregmolnar it is a private project. But the code is exactly same as from this repo - https://github.com/IamNaN/heroku_private_pub

curl http://localhost:9292/faye -d 'message={"channel":"/messages/new", "data":"hello", "ext":"{'private_pub_token':'mykey'}"}'

[{"channel":"/messages/new","error":"Incorrect token.","successful":false}]

gregmolnar commented 10 years ago

The curl request is not in the correct format as far as I see. It should be rather like this:

curl http://localhost:9292/faye -d 'message={"channel":"/messages/new", "data":"hello", "ext":{"private_pub_token":"mykey"}}'
randika commented 10 years ago

@gregmolnar that url was taken from a blog post and never checked it until now - It works just fine now. Really appreciate your help. thanks

gregmolnar commented 10 years ago

No worries, I am glad if I helped.