Heroku blocking frequent incoming HTTP Put - ruby-on-rails

I am currently using the free version of heroku. I have a cedar stack and I am sending up HTTP put request every 2 minutes from a client app to my web app. This will work for about the first few(1-6) request but then heroku blocks my incoming request. I've been looking all over the heroku support and I do not see anything about blocking HTTP put request. The only information I've found is that HTTP request have to be under 200 characters. I was wondering if anyone has had a similar problem. If so, how did you allow your web app to receive frequent HTTP request?
Thanks!

Found my problem. I had a bug in my client code which was using up all my sockets.

Related

ngrok tunnel not returning the control to the caller

I am not sure the title of the posting truly describes my issue but here is what's happening, in more details. I have an ASP.Net MVC application that redirects to a page hosted in an external system. This external hosted page is used to enter the details of a credit card in order to process a payment. Once the payment is processed, the hosted payment page is sending an HTTP POST to a webhook URL which was provided by me, when the transfer to the HPP was made. I have a Web API controller in my ASP.Net MVC application and this will be used to receive the webhook call. Now, to test it while I am running everything locally, I had to use ngrok to create a private tunnel between the HPP and my local Web API endpoint.
I have a breakpoint in my Web API controller and I am getting the data sent by the HPP, data that contains details about the approved payment. The controller responds with an HTTP 200 which I see it in the ngrok console:
For some reasons, this HTTP 200 is not propagated back to the HPP which should display a back button to yield control back to my web application where we all started in the first place. Instead, the browser is directed to an URL which is the exact URL for the webhook, the one that was provided when the transfer to the HPP is made:
Any idea why this is happening? Is the ngrok not returning the HTTP 200 back to the caller, which is the hosted payment page?
Any suggestions would be greatly appreciated.
TIA,
Eddie
Turns out that this is not an issue with ngrok. The remote Hosted Payment Page (HPP) is not sending an HTTP POST to a RESTful endpoint, as I erroneously assumed. Insted it is returning to a specified URL and sends the response as hidden fields.
So if anyone is ever facing the same situation, please make sure you understand exactly the behaviour of the remote server. This could send the response as an HTTP POST sent to a specified URL or could yield the control back to your application by means of navigation where the response is send as hidden fields (HTTP POST with content of type "application/x-www-form-urlencoded").

IOS: How to disable the user_session in the HTTP request

I'm working on supporting login by Github OAuth. But I encounter a problem:
When I log in to the Github once, the subsequence OAuth requests will fail with the 302 HTTP status.
When the OAuth request failed, the HTTP request is as follow:
The HTTP response is as follow:
I know the 302 response is caused by the "user_session" in the HTTP request.
My question is that is there any way to disable the user_sesion in the HTTP request. I want to send a totally new HTTP request for each OAuth request.
Thanks!
I tried the solution at Disabling cookies in WKWebView. But it doesn't work for me.
After using
myRequest.httpShouldHandleCookies = false
The WKWebView stops working. I guess it may be caused by the server cannot add cookies to our web browser.
The solution described at https://stackoverflow.com/a/31803708/10399490 works for me.
Just remove the cookies added by the Github.
I haven't verified whether the solution introduces any other side effects

How to uniquely identify remote request host

I'm building an API with Rails that is going to receive HTTP requests from other sites.
Every time a new request is issued, I need to know in my app if this site has already sent this request. So, I'm wondering if there is a way to uniquely identify the site sending the request. I'm thinking of using request.remote_ip however if the site is on a shared hosting, it would share the same IP address with other sites.
Is there any other way to identify the remote origin?
If the request is issued from an API client then the IP is all you have that you can (somewhat) rely on.
And as you mentioned this is not really unique (proxy, shared hosting, ...).

Ruby on Rails request in background

In my Ruby on Rails app, a user can grant me permission to tweet on their behalf, so they can send prefilled tweets from the application. This is the flow:
request to my server
server request to twitter server
based on the response of twitter, my users gets a response.
The request to twitter blocks my app. I use ActiveJob with resque for other communication with 3rd party applications and e-mail, but in this case I want to give the user response based on the twitter server response.
Is it possible to somehow do?:
request to my server
server request to twitter server
put this in wait so my server can serve other requests
get notified on twitter server response and send response to my user
It is not a problem that my user sending the tweet has to wait. I just do not want other users to wait on that.
One solution is to use ActiveJob and rescue to request from twitter and when twitter responds, you can use a realtime engine to respond back to the user.
Another solution is to use a server that supports multithreading (puma, rainbows!..).
I personally think that I would use a realtime service to solve this problem. Although it adds some overhead but on the long run it will help sustain a higher number of concurrent users.

Does creating a Twilio Capability Token require a request to Twilio's servers?

Does creating a Twilio Capability Token require a request to Twilio's servers?
If I understand correctly, creating a Twilio Capability Token involves some kind of encryption process that happens exclusively on my own server. When I call the library to create one, it is not making a call to Twilio's servers, correct?
If it is purely an encryption process, is it an encryption process that's designed to be "slow". If so, how slow?
I do believe that the creation of the token according to the C# Api, all happens on your own server. The process creates a Json Web Token and that is what is returned from the GenerateToken call. I cannot see anything that would cause the above call to be slow at all.
I know from my server side code, that this process is actually blindingly fast, in our production servers, when a token expires for a Twilio client, it requests a new one from the server and then initialises itself again, this process takes less than 2 seconds to complete and the client is once again able to either make or receive calls, depending on the allowed capabilities.
Perhaps if you share more about what you are experiencing as slow, one would be able to help more?
I hope this helps.

Resources