HTTPS Statement to Powershell: itgenboe314 The underlying connection was closed: An unexpected error occurred on a receive

I want to automate running of an application, and got the suggestion of using a curl statement with username/password and to use task scheduling.

As an alternative, I want to use Azure Automation, and then need a corresponding HTTPS statement.

Is that possible, and what is then the correct format for including username and password in the header?

What kind of application does it concern? Running an application module on Invantive Cloud (Invantive App Online)?

If so, the curl statement can be projected 1:1 as HTTPS GET or POST request.

What problem do you run into using the request?

Can you explain the relationship to Powershell?

Can you share the HTTPS request (excluding user name/password)?

What is the code of the module?

When it concerns another Invantive product, please elaborate.

I want to have a schedule running an Invantive Cloud App made with assistance from Invantive to synchronize Visma.net data to Azure SQL. Firstly, I have a curl that works, but I do not have a server to schedule it on. Thus I was recommended Azure Automation and runbooks, which is a cloud PowerShell in essence.

The Curl working is:

curl --user <username:password> https://<invantive cloud-app url>

I then set up the following powershell:

$username = "username"
$password = "password" | ConvertTo-SecureString -asPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($username,$password)
$res = Invoke-WebRequest -Uri "<URL>" -Credential $cred -UseBasicParsing

This works fine for small data transfers, but when I do the larger tables, the script runs for about 15 minutes and then stops with the following error message:

Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a receive. At line:4 char:8 + $res = Invoke-WebRequest -Uri "https://app-online.cloud/apps/4e6378a4 … + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Any suggestions to what can be wrong?

First hunch is a time-out.

The use of Invoke-WebRequest can be combined with a time-out. However, none is present and the default is 0 (indefinite) according to the PowerShell documentation at Invoke-WebRequest (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Docs.

So a time-out is unlikely.

Alternatively, the Invantive App Online server can have closed the connection. Maximum runtime for a request on Invantive App Online and Invantive Bridge Online is 6 hours, but something may have a caused an earlier end.

The easiest to analyze this is to visit Invantive App Online Monitoring at https://app-online.cloud. It displays all requests of the last 8 hours. Find your request and click on it to view the details (more information on More insight with new Bridge Online Monitoring).

Is there an error code or exception listed in the details?

Do the individual steps at the end provide a hint?

Is it possible to (anonymized) include a full screenshot of the details in Invantive App Online Monitoring in your answer?

See screenshot below:

From my Azure-people I`m asked whether it is possible to get a “202 ACCEPTED” back as a response when the job starts?

It is unclear why a HTTP 202 is needed. A HTTP 202 according to the specification is for asynchronous requests, whereas execution here takes place synchronously.

Best is to ask the Azure-people to extend the topic here.

The abortion of the job after 258 seconds (which is close to 256 seconds) might relate to another topic, in which after exactly 256 the download is finished. It seems related to an internal time-out of Invantive Cloud when no data (no single row) at all is returned during 256 seconds, which is happening here since another identical request is still running.

Please include the monitor request value in the blue bar in an answer. Using that information it can be looked up.

With this information we will try to fine-tune the behaviour.

Please note that the job does not start at all, since an itgentmm022 message is displayed:

itgentmm022
Another identical active request is currently taking up the single available slot.
Wait till the other request finishes.

Best is to wait for the other request to finish or try to use “Abort Request” on it. In case another user runs the request, it is not possible to abort it for a normal user.

So best solution is to re-run the request and run it alone for now. In the App Online Monitoring a user can see whether he has it already running.

The monitoring request has been received through another channel:

Monitoring Request 80000079-0803-6e00-b63f-84710c7967bb