Closed johncox00 closed 8 years ago
Doesn't seem to be related to rest-firebase. Could you try to run it standalone? Also perhaps checking your Internet?
Turns out it was something to do with docker on my machine. Really strange. Sorry for the erroneous question here. Now I just have to figure out what I'm getting a 401 when trying to .put
to firebase.
No problems. Good luck!
I'm getting a authorization error now. Anyway I can get some direction? john@mach19.com
Could you provide detail? There are three ways to give auth. One you give secret, and rest-firebase would generate the auth for you. The other is you give secret as the auth, acting as a never expired auth. The last one is you just give the auth generated from else where. Note that normally the auth would expire in 24 hours, so you need to update auth somehow in this case.
Thanks for the reply. Sure. I've tried a lot of ways. Here's the latest:
$firebase_stream = RestFirebase.new( site: FB_URL,
secret: FB_SECRET,
d: {:uid => Time.now.to_i, :app => "sectretapp"},
log_method: method(:puts),
error_callback: method(:p),
timeout: 10,
max_retries: 3,
retry_exceptions: [IOError, SystemCallError, Timeout::Error],
auth_ttl: 82800
)
$es = $firebase_stream.event_source('threads')
$es.onopen { |sock| puts sock }
$es.onmessage{ |event, data, sock| puts event, data }
$es.onerror { |error, sock| puts "Streaming error: #{error}" }
$es.onreconnect{ |error, sock| puts error; true }
Then I fire uprails c
:
Loading development environment (Rails 4.2.6)
2.2.2 :001 > $es.start
=> #<struct RestFirebase::Client::EventSource client=#<struct RestFirebasesite="https://yet..., headers={"Accept"=>"..., query={:auth=>"eyJ..., json_request=true, max_retries=3, retry_exceptions=[IOError, Sy..., timeout=10, max_redirects=5, error_handler=#<Proc:0x007..., error_detector=#<Proc:0x007..., json_response=true, log_method=#<Method: Ob..., cache=nil, expires_in=600, d={:uid=>14616..., secret="e2IgL1YqUoU..., auth="eyJ0eXAiOiJ..., auth_ttl=82800, iat=1461675335, config_engine=nil>, path="/", query={}, opts={}, socket=nil>
2.2.2 :002 > RestCore: spent 0.664393 Requested GET https://something.firebaseio.com/.json?auth=[omitted]
RestCore: spent 0.619017 Requested GET https://s-usc1c-nss-121.firebaseio.com/.json?auth=[omitted]&ns=something&sse=true
#<RestFirebase::Error: [401] nil from https://s-usc1c-nss-121.firebaseio.com/.json?auth=[omitted]&ns=something&sse=true>
Streaming error: [401] nil from https://s-usc1c-nss-121.firebaseio.com/.json?auth=[omitted]&ns=something&sse=true
Note the 401.
Did you set your Firebase rule? You could do that from your Firebase console. Since you're requesting threads
, make sure that you have made it accessible.
OK...I'm an idiot. That was exactly the issue. Thank you for pointing me int he right direction. You're a gentleman and a scholar.
Haha, no problems. I think I did similar things before. They should probably give better error messages instead of generic 401.
I have an initializer:
When runing
rails s
I get the following output:Any insight?