Getting 403 when executing request from amazon server - c#

Very same code works fine from other locations, but whenever is run from amazon server it gets 403.
We tried "everything":
checking with postman
copying cookies
copying / not copying the headers.
whatever we do we get 403 when code / request is run from amazon server. What is even more interesting: browsers work fine (you can get to the same link from any browser without any errors). So the conclusion is like "something blocks requests that are not sent with the browser and we can't impersonate aby browser".
thanks in advance!
PS as far what i know it's fine from some other hosting services, only Amazon seems to be blocked.
Requests are not passed from any app / any language, including Postman but they're fine when any browser is used. So it's like "something" detects the original source of request and if request comes from amz "it" blocks the request. Everything is fine when not used from amz servers)

You can send your request to https://requestbin.com/ to analyze better what is going out from the Program and then change the missing parameters.

Related

Understanding a 400 bad request only on chrome

I get this error with my .Net app but it only occurs on chrome on 2 pages on my site and only on my network.
What does the notes in the image mean? If I hit refresh it works fine. How do I figure out what the headers are and if it's a network or security thing?
Clear your cookies. This must be caused by an invalid cookie. Had the same issue and clearing the cookies worked for me
Followings can be possible options to look at:
As you getting issues in Chrome, clear cache/cookies
Error 400: The Web server thinks that the data stream sent by the client (e.g.
your Web browser) was 'malformed' i.e. did
not respect the HTTP protocol completely. So the Web server was
unable to understand the request and process it.
It indicates that the two systems (our robot and the Web server)
fundamentally disagree on the syntax of HTTP data streams. Mare sure you are not calling HTTPS from HTTP?
Hope this helps!

Client doesn't call web.api json service

I have a strange problem where a program using a simple external call to an web.api.
The program is working on about 50% of the clients I've tried it on.
The program uses a WebClient to fetch the data.
On my local machine where the program works, I have analyzed the call to the json service via fiddler and everything works fine, a request is made and json is returned.
When checking fiddler on a client where the program doesn't work, there is not even a request being done according to fiddler.
This makes me believe that there might be some policy on these computer that does not allow external calls.
Any tips would be greatly appreciated!
/Peter

See Raw Response to a WCF Call

I'm building out a simple C# application that integrates with a SOAP web service. I add the service reference to the appropriate WSDL and everything works out fine so far.
Occasionally, the server's firewall will respond with a 503 error before the request gets a chance to hit the web service. That 503 error also contains some HTML with an ID number (which changes each time) that I want to capture.
If I catch the exception, it doesn't give me the full message - just the re-formatted basic exception that says the server is too busy.
I tried the message inspectors suggestion from this post:
Intercept SOAP messages from and to a web service at the client
...and it gives me the outbound request, but it never hits the AfterReceiveReply call, so the response isn't captured.
I've also tried subscribing to all of the channel's major events (Faulted, Opening, Opened, UnknownMessageReceived, etc), and I've tried inspecting the channel when I catch the exception, but nothing seems to work.
Any thoughts or suggestions?
Why not just run fiddler on the machine your soap client is running on and intercept and inspect the traffic that way?
Turn on WCF Tracing. In particular, Message Logging.
It seems like disabling SOAPProcessing in the .config file may be a step in this direction, but I was unable to figure out how to enable this setting via code (and I cannot use a .config file in my final application because this is a plugin and the parent app's .config file is dynamically generated each launch).
I was able to work around this somewhat. In my situation, I had separate dev and production servers. The 503s errors were happening mostly on the production server (likely due to the firewall being sensitive about a different hostname in the API requests), so I ended up with a solution that duplicated the API requests and sent them over to the production server.
(This was okay, because the production server was not configured with anything that would be affected by any API requests that made it through the firewall. The requests would just be considered invalid.)
I did this by using message inspectors to generate the last outgoing request. Then for each outgoing request, I generated a new WebBrowser control, set the proper headers (SOAPAction and all that), re-injected the security credentials (the message inspector stripped them out at runtime), and then posted the request to the production server with that WebBrowser control. The WebBrowser instance's DocumentCompleted event let me dump the result and search for the ticket ID when appropriate.
Not exactly glamorous, but it works well.

Webservice taking long time to response

I have a client server application. My server is in PHP, Mysql and Apache and client is developed using C# windows Form. I have SOAP WSDL webservice for client server communication.
Recently I found a problem, when my client sends the request, response comes after very long time (like 3/4 mins to some hrs.), and sometimes I never gets response. I have checked all the timeout value in client (httpwebrequest timeout, readwritetimeout) as well as server(timeout, keepalivetimeout) side, the max value I have is 5mins (for httpwebrequest readwritetimeout). So can anybody tell what would be the problem? Why it is taking hours to get response or not geting any response?
In my experience, problems like these come with the web-service connection being blocked by a firewall, or a wonky proxy in the way. Check that this is not the issue.
You should first begin be locating the problem by narrowing down the options. Have you tried calling the web service on the server locally, see if you get the same problem - if you don't then it is with high likeliness certainly a connection problem.
To also rule out the client having problems, try using something like http://www.soapui.org/ instead to call your server web service.
Where are you calling the server from? Are you sure the device you call it from is not being IP-blocked, and are you sure your web service is able to access its database from where it is being run.
Does the MySQL user defined for your server API to use have access from the IP of the server. MySQL users are often blocked by IP as well.
If you're running it all locally, are you sure your IIS Express settings/virtual folders are not jumbled up and the URLs are resolving wrong. Try creating the virtual folder again to rule out this. Even when running locally, remember to check that the MySQL user has access from your local IP.
Here's a few things I usually check when I have issues like yours.

Application hanging in a web service

I have an application that users were complaining that it hangs when the user trys to perform a certain action. I found it that it is hanging in a web service call. The web service is running on a remote server. I can't figure out how to debug into the web service through VS when the code is on a remote server.
How do I find out in the web service where exactly the code is hanging?
If you don't have access to the source of the web service then you're not going to be able to "debug" it. If you want to try to externally debug it then you can create a page that sends various inputs to it (some that should work, some that should error out, etc). You can then access this page in a browser that has developer tools (I would recommend Firefox w/ Firebug or Google Chrome) and then look at how long the calls are taking. Google Chrome will show you how long it took to send the request, how long it waited, how long it took to receive, etc. If it IS the actually web service and you don't have access to it then it would be odd that you were responsible for fixing this issue. I have a feeling though, if this is a robust web service, you're going to find that you're either having a networking issue or your sending it some invalid input or something along those lines.
If you do have access to the source code then simply run the web service locally and point your local version of the application at the local version of the web service. Any breakpoints you put in the web service will hang the application and you will be able to step through it just like you can non-web-service code.
In your own code, take a look at what is going on with the web service call. e.g Does it throw a fault? Timeout? Does it ever return a successful response? If not, are you sending valid data?
If the web service call is successful but just slow, consider how you might make your application appear to be more responsive. One possibility is to use Asynchronous Programming.

Categories