Adobe Flex 4.6 WebService request timeout - web-services

The code to get connected to my WebService (Lotus Notes Database) is created by the Flash Builder over "Data/Connect with WebService...". All works fine, but I have a problem to increase the request timeout. The API says that you can set the request timeout like this:
_serviceControl.requestTimeout = 300;
On a iOS (iPad) it seems to be work all fine. But if I run my app on desktop or on an android smartphone this only works if I set up the request timeout lower than ~30 seconds. If I don't set up the request timeout or higher than 30 and my app needs longer than 30 seconds to wait for an answer/result the "_serviceControl" fires an FaultEvent with the message:
body = ""
clientId = "DirectHTTPChannel0"
correlationId = "CDED773E-34E5-56F8-D521-4FFC393D7565"
destination = ""
extendedData = (null)
faultCode = "Server.Error.Request"
faultDetail = "Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: "http://...?OpenWebService" errorID=2032]. URL: "http://...?OpenWebService"
faultString = "HTTP request error"
headers = (Object)#1
DSStatusCode = 0
messageId = "91D11378-49D4-EDF7-CE7A-4FFCB09EBC47"
rootCause = (flash.events::IOErrorEvent)#2
bubbles = false
cancelable = false
currentTarget = (flash.net::URLLoader)#3
bytesLoaded = 0
bytesTotal = 0
data = ""
dataFormat = "text"
errorID = 2032
eventPhase = 2
target = (flash.net::URLLoader)#3
text = "Error #2032: Stream Error. URL: "http://...?OpenWebService"
type = "ioError"
timestamp = 0
timeToLive = 0
Any idea why this happens?

I had the same problem, requestTimeout didn't work.
If someone is looking for an answer, this configuration works fine for me :
import flash.net.URLRequestDefaults;
URLRequestDefaults.idleTimeout = 120000; //note this value represents milliseconds (120 secs)
Have a look here for more details : Flex HTTPService times out anyway

Though it seems to be assumed that requestTimeout doesn't work. It actually does... the 1st time.
After the 1st request, the requestTimeout is set in
HTTPService.channelSet.currentChannel.requestTimeout
If you have to change the timeout, you will want to do it there.
To see the specific offending code, see AbstractOperation.getDirectChannelSet(). Even for different instances of HTTPService, it pulls from:
private static var _directChannelSet:ChannelSet;
_directChannelSet is only instantiated once, and the requestTimeout on it is only set on creation, so even if you change the requestTimeout on HTTPService, it won't reflect in the request.

Related

Problem using authorization_code on deployed IdentityServer4 for a PowerBI Extension. What am I missing?

This one has been driving me mad for a couple of days and I can't find a solution. Can someone point me towards one? Thank you in advance!
What I want:
I want to successfully use the authorization_code flow for a Power BI Extension.
What I've done:
I've setup an OAuth2 flow in Power Query M and when I target my localhost IdentityServer, I can login with the user login screen and I get an Access Token that Power BI can use. This works, but it doesn't work on a published IdentityServer (same code, same database). So what am I missing?
Here's what happens:
I have this Power Query M code (it's pretty standard, I found it online and it works on localhost):
StartLogin = (resourceUrl, state, display) =>
let
authorizeUrl = oauthUrl & "connect/authorize?" & Uri.BuildQueryString([
response_type = "code",
client_id = client_id,
redirect_uri = redirect_uri,
state = state,
scope="myscope"
])
in
[
LoginUri = authorizeUrl,
CallbackUri = redirect_uri,
WindowHeight = windowHeight,
WindowWidth = windowWidth,
Context = null
];
FinishLogin = (context, callbackUri, state) =>
let
// parse the full callbackUri, and extract the Query string
parts = Uri.Parts(callbackUri)[Query],
// if the query string contains an "error" field, raise an error
// otherwise call TokenMethod to exchange our code for an access_token
result = if (Record.HasFields(parts, {"error", "error_description"})) then
error Error.Record(parts[error], parts[error_description], parts)
else
TokenMethod("authorization_code", "code", parts[code])
in
result;
TokenMethod = (grantType, tokenField, code) =>
let
queryString = [
grant_type = grantType,
redirect_uri = redirect_uri,
client_id = client_id,
client_secret = client_secret
],
queryWithCode = Record.AddField(queryString, tokenField, code),
tokenResponse = Web.Contents(oauthUrl & "connect/token", [
Content = Text.ToBinary(Uri.BuildQueryString(queryWithCode)),
Headers = [
#"Content-type" = "application/x-www-form-urlencoded",
#"Accept" = "application/json"],
ManualStatusHandling = {400}
]),
body = Json.Document(tokenResponse),
result = if (Record.HasFields(body , {"error", "error_description"})) then
error Error.Record(body[error], body[error_description], body)
else
body
in
result;
What happens is that an IE frame pops up to prompt for my credentials:
The normal login page
Once I login on localhost, I get my AccessToken, life's good :-)
However, once I login on the deployed IdentityServer, I get this one, a 400:
Failing on deployed IdentityServer
The address is: res://ieframe.dll/http_400_webOC.htm#https://identityserverurl/Account/Login?ReturnUrl=%2Fconnect%2Fauthorize%2Fcallback%3Fresponse_type%3Dcode%26client_id%3DPowerBI%26redirect_uri%3Dhttps%253A%252F%252Foauth.powerbi.com%252Fviews%252Foauthredirect.html%26state%3D852bddfc-638c-44f6-90be-a04346908753%26scope%3Dmyscope
I think the problem has something to do with Internet Explorer and the way the window is being presented, but I can't figure out why it DOES work on localhost, just NOT on a deployed server. The client settings are identical on both localhost and on the deployed IdentityServer (it's on a develop server; they target the same database).
I know on a deployed IdentityServer the home page is not available, so the "https://identityserverurl/" will give a 404. Is something similar going on here?
What am I missing?
Any help is much appreciated! It's the final step to getting it all to work.
Best regards,
Remco
Update: Added IdentityServer logging and Fiddler Trace:
GET /connect/authorize?response_type=code&client_id=PowerBI&redirect_uri=https%3A%2F%2Foauth.powerbi.com%2Fviews%2Foauthredirect.html&state=d2f420fb-a98a-4327-b8f1-ebb8937f8b00&scope=openid%20profile%20offline_access%20myscope HTTP/1.1
GET /Account/Login?ReturnUrl=%2Fconnect%2Fauthorize%2Fcallback%3Fresponse_type%3Dcode%26client_id%3DPowerBI%26redirect_uri%3Dhttps%253A%252F%252Foauth.powerbi.com%252Fviews%252Foauthredirect.html%26state%3Dd2f420fb-a98a-4327-b8f1-ebb8937f8b00%26scope%3Dopenid%2520profile%2520offline_access%2520myscope HTTP/1.1
There's not much else going on. It just simply stops when I click login.

Session Timeout on Application level in Oracle Apex

In my Application ID I changed in security attributes -> Maximum Session Idle Time in Seconds as 900 seconds, but issue is if I am on same page number it gives me session timeout message.
I want session timeout on user's movement over the page or other tabs it should not be restricted because all my application work is in mostly one page.
Session timeout is managed by the web application server and it needs a request or form submission to tell him, hey I'm alive, dude please don't kill the session, so for that reason you need to create an ajax request to tell web server you are still there.
You can use this script to detect user inactivity
var IDLE_TIMEOUT = 60; //seconds
var _idleSecondsCounter = 0;
document.onclick = function() {
_idleSecondsCounter = 0;
};
document.onmousemove = function() {
_idleSecondsCounter = 0;
};
document.onkeypress = function() {
_idleSecondsCounter = 0;
};
window.setInterval(CheckIdleTime, 1000);
function CheckIdleTime() {
_idleSecondsCounter++;
var oPanel = document.getElementById("SecondsUntilExpire");
if (oPanel)
oPanel.innerHTML = (IDLE_TIMEOUT - _idleSecondsCounter) + "";
if (_idleSecondsCounter >= IDLE_TIMEOUT) {
alert("Time expired!");
document.location.href = "logout.html";
}
}
Check this post Detecting user inactivity over a browser - purely through javascript

How to set the max receive message length in Google Cloud request?

I have the following Google Cloud call:
var builder = new TextToSpeechClientBuilder();
builder.JsonCredentials = #"...";
var client = builder.Build();
var data = client.SynthesizeSpeech(new SynthesisInput { Ssml = text },
new VoiceSelectionParams { LanguageCode = culture.TwoLetterISOLanguageName },
new AudioConfig { AudioEncoding = AudioEncoding.Linear16, SampleRateHertz = 8000 }).AudioContent;
It throws the following exception:
Grpc.Core.RpcException: 'Status(StatusCode="ResourceExhausted", Detail="Received message larger than max (4675411 vs. 4194304)")'
The request is less than 2000 bytes, so it seems that the response is too big. The server wants to send the response, but the client can't accept it.
How to increase this limit?
UPDATE: Since version 2.2.0 it is possible to set the max response size:
var channelOptions = GrpcChannelOptions.Empty
.WithKeepAliveTime(TimeSpan.FromMinutes(1))
.WithEnableServiceConfigResolution(false)
.WithMaxReceiveMessageSize(1024 * 1024 * 1024);
var builder = new TextToSpeechClientBuilder();
builder.JsonCredentials = jsonCredentials;
builder.GrpcChannelOptions = channelOptions;
In order to overcome the error Received message larger than max (4675411 vs. 4194304), you need to set the inbound message size to a greater value. You can do it when instantiating your builder, similarly as when creating a channel. Below, it is how you can do it:
textToSpeechClient = TextToSpeechClient.create(TextToSpeechSettings
.newBuilder()
.setTransportChannelProvider(
TextToSpeechSettings.defaultGrpcTransportProviderBuilder()
.setMaxInboundMessageSize(8790801)
.build())
.build());
Here is the documentation for the setMaxInboundMessageSize method.
UPDATE: As I understand you want to use C# and since I could not find a method to set the inbound's message size, such as in Java (above). I have opened a a Public issue within Google. Although, I do not have an ETA for it, you can keep track here.

Copy Web Service in SharePoint for Office 365

I am trying to upload files greater than 100 MB size to SharePoint Portal for Office 365. I have tried three different ways to achieve the same.
Copy Web Service, along with the httpRuntime Setting in place with maxRequestLength set as 2097151 and executionTimeout as 14400. Also, I did try setting the Timeout as "Infinite" and "60000".
Error: The underlying connection was closed: An unexpected error occurred on a send.
Web Client, using UploadDataAsync method to "PUT" the file bytes to the destination Url. Even with this, the httpRuntime setting was in place as above.
Error: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
HttpWebRequest, with ServicePointManager.Expect100Continue set to false. Also tried the same with SendChunked as both true and false.
Error: The request was aborted: The request was canceled.
Apart from all these, I have also added
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
System.Net.HttpWebRequest webRequest =
(System.Net.HttpWebRequest) base.GetWebRequest(uri);
webRequest.KeepAlive = false;
return webRequest;
}
in the proxy class generated for Copy service. The limitation is I can't use CSOM to upload the files.
And still the Upload request times out every time. Any help would be very much appreciated.
Thanks in advance.
Try using the following piece of code :-
WebRequest webRequest = WebRequest.Create(url);
HttpWebRequest request = (HttpWebRequest)webRequest;
request.CookieContainer = CookieContainer;
request.Method = "PUT";
request.KeepAlive = true;
request.Timeout = Timeout.Infinite;
byte[] buffer = new byte[1024];
using (Stream stream = request.GetRequestStream())
{
using (MemoryStream memoryStream = new MemoryStream(fileBytes))
{
memoryStream.Seek(0, SeekOrigin.Begin);
for (int i = memoryStream.Read(buffer, 0, buffer.Length); i > 0;
i = memoryStream.Read(buffer, 0, buffer.Length))
{
stream.Write(buffer, 0, i);
}
}
}
WebResponse response = request.GetResponse();
response.Close();
Have you tried to change the default maximum upload file size?
What version of SharePoint are you using?

Asp Classic Calling webservice with SOAP Request

I'm trying to get a response from a ASP.NET webservice without using the get parameters. I have the following code.
strBarcode = "ABC123
strURL ="http://serverName/BarcodeGenerator.asmx"
Set xmlReq = Server.CreateObject("Msxml2.DOMDocument.3.0")
Set xmlResp = Server.CreateObject("Msxml2.DOMDocument.3.0")
Set httpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlReq.async = false
strXML = CStr(CreateRequest(strBarcode ))
xmlReq.loadXML(CStr(strXML))
//Open, async
httpReq.open "POST", CStr(strURL), true
httpReq.setRequestHeader "Host", "serverName"
httpReq.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
httpReq.setRequestHeader "SOAPAction", "http://tempuri.org/GetBarcode"
httpReq.send(xmlReq)
strDone = "0"
bTimeout = false
dStart = Now()
dEnd = Now()
lCounter = 0
lCounterPrev = -1
intStatus = 0
Do while intStatus <> 4 and (Not bTimeout)
dEnd = Now()
lCounter = DateDiff("s",dStart,dEnd)
if lCounter > 30 then bTimeout = True
%>. <%
'Wait a second
httpReq.waitForResponse 1000
intStatus = httpReq.readyState
Loop
If httpReq.readyState = 4 Then
bTimeout = false
Set xmlResp = httpReq.responseXML
%>
Status: <%=httpReq.statusText%><BR>
Response: <%=httpReq.responseText%> <BR><BR>
<%
Set nodes = xmlResp.getElementsByTagName("GetBarcodeResult")
If (nodes is nothing) THen
%>Nodes is NULL<BR><%
Else
%>Number of Nodes: <%=nodes.length%><%
End IF
Set node = nodes(0)
url = node.nodeValue
End If
The status is
Status: Bad Request
and the response is
Response: Bad Request (Invalid Hostname)
What am I doing wrong?
Your code is attempting to set the Host header itself. You should not be doing this.
ServerXMLHTTP will do this for you drawing the host string from the URL provided. By attempting to add it yourself you are corrupting an important criteria for the HTTP protocol. Host is the most fundemental header in the 1.1 protocol, it is the only header that must be present in a 1.1 request.
I'm not sure why you are using an asynchronous request and WaitForResponse just to detect a timeout. Why not use the setTimeouts method and a synchronous request?
This article (now via web.archive.org for posterity) explains it best, but basically, due to IIS configuration the server was unable to locate itself (the classic-asp and webservice were hosted on the same server). There are no problems with the code.