dojo timeout exceeded on xhr post - dojo

In an xpages application I get a dojo timeout exceeded response, if the client uses a very slow internet connection:
Screenshots Google Developer Tools:
Thanks in advance for any response :)

This snippet allows you to extend the timeout https://openntf.org/XSnippets.nsf/snippet.xsp?id=extend-partial-refresh-timeout.

Related

Navigator.sendBeacon not working with Authorization Headers

Recently chrome stop support for synchronos xmlhttprequest on page unload or beforeunload event https://www.chromestatus.com/feature/4664843055398912
i try this solution Perform an asynchronous service get when closing browser window / tab with Angular but not seems to be working in latest chrome versions
Now i am using navigator.sendbeacon api like this
let headers = {
type: 'application/json; charset=utf-8',
'authorization': `bearer ${token}`
}
let blob = new blob([json.stringify({a:"9"})], headers);
navigator.sendbeacon(uri, blob);
Api is throwing 401 so seems like authorization is not working,
Is there any other alternative to navigator.sendBeacon
At time of this writing, no. Chrome (and probably other browsers too more sooner than later) will disallow XHR-sync because of bad UX to the user (the browser hangs if user is closing the tab and an XHR-sync request is made).
There are a few workarounds though, but each have their drawbacks as well
Use the new (and experimental) sendBeacon API - sendBeacon simply "queues" the request and this guarantees that the request will be fired even on page unload. That too without blocking the UX. Some limitations with this are that you cannot change request headers by default. If you DO need to add custom headers, you will have to use a blob, and that too the headers should be CORS-friendly. And will not work on older browsers (looking at you, IE)
Use fetch() API + keepalive flag - but this again works if you request headers are on the CORS-safelist. Basically if your fetch() request has certain request headers, then a preflight request can be made for security reasons. If such a preflight request is made, then the fetch() + keepalive is disallowed by some browsers. Basically you need to keep your request simple for this to work. For example, Such as you cannot use a content-type=application/json here. One workaround for this is to send data as text/plain and get your server to handle it accordingly.
Some more info on CORS simple vs preflight requests can be found here.
Chrome does allow a temporary workaround but this will work only till Oct 2020. More info on that here.

How to post a video to the Thingworx platform

I have a short video (about 6 seconds) and I want to post it to a service in Thingworx, where the service has a parameter of type Blob. I tried to post the Video using Postman client but I always have a 403 error; where the request is legal but the server refuses to respond to it. Could you help me please finding the right way to upload the video files?
Postman request
Postman request
enter image description here

Jmeter - POST API not working

I am new to Jmeter and have been struggling to get it working to test my POST API. It works fine for a GET API call where I pass the parameters through the Parameters tab.
Details here:
server name: localhost
port: 8080
path /registerMobileUsingCode
In the request body, I am sending the following:
{
"clientName": "DemoOrg",
"code": "9880007615",
"languageId": "1"
}
My Jmeter setup looks like this:
And my HTTP Request Header looks like this:
The API is in production and works fine with postman.
I am just unable to get it working through JMeter. It is obvious that I am doing something wrong but can't figure out what despite having spent a considerable amount of time Googling for solutions.
Any help would be much appreciated.
UPDATE - 1 - Updated with jmeter log as suggested
Thread Name: Thread Group 1-1 Sample Start: 2017-08-09 17:03:41 IST Load time: 1604 Connect Time: 1525 Latency: 1604 Size in bytes: 399
Sent bytes:251 Headers size in bytes: 213 Body size in bytes: 186
Sample Count: 1 Error Count: 1 Data type ("text"|"bin"|""): text
Response code: 500 Response message: Server Level Exception
encountered
Response headers: HTTP/1.1 500 Server Level Exception encountered
Date: Wed, 09 Aug 2017 11:33:43 GMT Access-Control-Allow-Origin: *
Content-Type: application/json Transfer-Encoding: chunked Server:
Jetty(9.2.16.v20160414)
HTTPSampleResult fields: ContentType: application/json DataEncoding:
null
UPDATE-2 - Using Postman and JMeter Recorder
As suggested by #Dimitri T, I downloaded the Linux version of Postman and started it with --proxy-server=localhost:8888.
I was now able to make a Postman request and capture the request in JMeter. Here is what the request looked like:
Jmeter capture of a Postman Request
As you can see, nothing radically different from what I did. However, this DOES work! So hurray!
If your application works fine with Postman the fastest and the easiest way of building JMeter test plan will be just recording it using JMeter's HTTP(S) Test Script Recorder.
Prepare JMeter for recording (you can do it in a few clicks via JMeter Templates Feature)
from JMeter's main menu choose File -> Templates -> Recording and click "Create"
Expand Workbench - HTTP(S) Test Script Recorder and click "Start"
Prepare Postman for recording
In order to "tell" Postman to use JMeter as a proxy you need to provide --proxy-server parameter to it like:
C:\Users\YOUR_USER_NAME\AppData\Local\Postman\app-x.x.x\Postman.exe --proxy-server=localhost:8888
Execute your requests in Postman
JMeter will capture requests, convert them into HTTP Request samplers and store them under Test Plan -> Thread Group -> Recording Controller
References:
JMeter Proxy Step by Step
How to configure Postman Native Client App to use an external proxy
By seeing the image you have attached you are missing / in the path.
the path should be /registerMobileUsingCode
if it is working fine from POSTMAN, then your port 8080 is fine.
Can you please confirm what is the data type of your request? looks like languageId is integer so you should be using languageId: 1, instead of languageId: "1". The integer should not be double quotes.

WCF REST StarterKit HttpClient: Timeout from HttpClient when going remote - works fine locally or via local proxy

I'm getting repeated Microsoft.Http.HttpStageProcessingException timeout exceptions while trying to use the REST Starter kit's HttpClient. This has been working fine when used locally, but is failing when going remote.
The client is a c# process that runs as a windows service and uses HttpClient for making REST calls to our Java app server running in Tomcat6. When I started troubleshooting this, I came across a similar post on MSDN's forums: http://social.msdn.microsoft.com/Forums/en/wcf/thread/88487549-ce45-49d3-95e4-7ed413cbcfbc
Unfortunately, I can't isolate it to simply a Content-Length problem.
If anyone has any suggestions on how to solve this problem, I would greatly appreciate it - even if it means using HttpWebRequest directly. I understand HttpClient uses HttpWebRequest under the hood, but perhaps it's making some assumptions.
Found the solution. It turns out that the default number of outbound http connections when using the HttpClient seems to be 2. After I used the ServicePointManager static singleton to set the DefaultConnectionLimit for my client AppDomain to 10, everything worked fine.
Now, this is a little concerning, however - because I'm used to writing multi-threaded apps and using the new .NET 4 Tasks - so I really don't like having hard limits on outbound connections. Can anyone provide any links that provide details on how the low-level .NET Http handling works and what knobs control what settings?
Thanks again for the help,
Bob
NEVERMIND - found it myself, should have googled first - this MSDN blog on the Http Client protocol provides a good description of what's going on under-the-hood:
httpclient protocol blog
If it works locally or remotely via Fiddler then it is a problem with HTTP proxy. Your current configuration is not using proxy but Fiddler by default uses proxy configured for IE.
Get the same problem and solution is to Dispose method on response (maybe method named Close may be more clear) else response still occupy the socket and you have to increase the DefaultConnectionLimit to open new socket for each new request untill max limit reach (dirty and slow).
So the solution was:
HttpResponseMessage resp = this.HttpClient.Delete(uri);//or verb get/post/put
try {
//.... do what you need with response
}
finally {
resp.Dispose(); //free the socket for a new request
}

XMLHttpRequest problem

I am writing one Web Application using XUL. In that Iam using AJAX XMLHttpRequest Object for sending request to server. When I use GPRS connection to send the request to the server from my web application the request is not going, but readyState has changed to 4 and status=0. If the request is not going out how the readyState is Changing.
The same Code working fine in local network. If I send the request to server from the browser using GPRS it is working fine. Can any body help me out in solving this problem.
Thanks in Advance.
the request is not going
How do you determine that?
Do you use the HTTP scheme? If so, status == 0 is an issue, (google says there are known quirks in Firefox).
status == 0 is also returned when the request is using a non-HTTP protocol. So if you're making a file:// request accidentally, it would explain all the symptoms...
[edit 2009-09-07]
Also found this issue: https://bugzilla.mozilla.org/show_bug.cgi?id=488605
aborted XMLHttpRequests have status==0 since Firefox 3.
[edit] I'm not /quite/ sure, but I think that cross-domain requests that are not allowed also end up with status == 0.