HEADERS = {
'X-Version' => 'V1',
'X-API-Key' => 123456,
'Content-Type' =>'application/json'
}
uri = "https://api.remoteserver.com/VerifyAPIKey"
conn = Faraday.new() do |f|
f.adapter :net_http_persistent do |http|
http.idle_timeout = 100
end
end
@response = conn.post do |req|
req.url URI(uri)
req.headers = HEADERS
req.body = body
end
If you notice, I configure the adapter of Faraday using net_http_persistent because I'm running an open-source Phusion Passenger server and we need a persistent connection because the Passenger is a multi-process which means it will spawn one or more processes
as the load increases. However at first request the api was
successfully authorized(see processID #26698) but on the next request I
got authorization error (processID #64121)
See the logs below:
I, [2019-04-01T18:20:29.611996 #26698] INFO -- Authorization is finished successfully.
I, [2019-04-01T18:20:29.611996 #26698] INFO Thread with name "MsgsQueue worker #47338607938600"
I, [2019-04-01T18:20:29.611996 #26698] INFO Thread with name "MsgsQueue worker #47338625106140"
I, [2019-04-01T23:20:09.341415 #64121] INFO Authorization error. Need to authenticate first!
I, [2019-04-01T23:20:09.341415 #64121] INFO Thread with name "LogsSender worker #47158391867980" is terminated!
I, [2019-04-01T23:20:09.341415 #64121] INFO Thread with name "LogsSender worker #42158391867991" is terminated!
Is there any settings in Faraday that I'm missing ?
Any help would be greatly appreciated. Thanks
--
You received this message because you are subscribed to the Google Groups "Philippine Ruby Users Group (PRUG/PhRUG)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-phil+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.