REST API

You have a question or need an advice about how to do something? Ask it here!
John2103
Posts: 31
Joined: 11 Nov 2019 16:32
REST API

Post by John2103 »

The GPIO client on my Windows Server runs on port 9001.

When I execute this command in curl I see:

PS C:\Users\Admin> curl.exe -X POST http://localhost:9001/commands `
>> -H "Content-Type: application/json" `
>> -d "[`"SHOW_ALERT_WINDOW TEST`"]" `
>> -u ProppFrexx:ProppFrexx -v
>>
Note: Unnecessary use of -X or --request, POST is already inferred.
* Host localhost:9001 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
* Trying [::1]:9001...
* Connected to localhost (::1) port 9001
* using HTTP/1.x
* Server auth using Basic with user 'ProppFrexx'
> POST /commands HTTP/1.1
> Host: localhost:9001
> Authorization: Basic UHJvcHBGcmV4eDpQcm9wcEZyZXh4
> User-Agent: curl/8.13.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 24
>
* upload completely sent off: 24 bytes

However, no message shows up in ProppFrexx (it is enabled in settings and options -> More Stuff).

Could it be that I did something wrong? Any suggestions on how I can troubleshoot or fix this problem would be greatly appreciated. Thanks in advance.
User avatar
radio42
Site Admin
Posts: 8926
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: REST API

Post by radio42 »

Please omit the [ and ] brackets from the command.
Ie. just use the SHOW_ALERT_WINDOW TEST as the command.
John2103
Posts: 31
Joined: 11 Nov 2019 16:32
Re: REST API

Post by John2103 »

Thanks for your quick response. I tried the following:

PS C:\Windows\system32> curl.exe -X POST http://localhost:9001/commands `
>> -H "Content-Type: application/json" `
>> -d "SHOW_ALERT_WINDOW TEST" `
>> -u ProppFrexx:ProppFrexx -v
Note: Unnecessary use of -X or --request, POST is already inferred.
* Host localhost:9001 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
* Trying [::1]:9001...
* Connected to localhost (::1) port 9001
* using HTTP/1.x
* Server auth using Basic with user 'ProppFrexx'
> POST /commands HTTP/1.1
> Host: localhost:9001
> Authorization: Basic UHJvcHBGcmV4eDpQcm9wcEZyZXh4
> User-Agent: curl/8.13.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 22
>
* upload completely sent off: 22 bytes

After the message “upload completely sent off: 22 bytes” curl hangs.

I also tried the same request with Postman (with and without the brackets). In both cases, Postman shows “Sending request” and then hangs.
Postman.png
Additional information: I have a Java Spring application that sends messages to the REST API. It works on another computer, but on this new computer it also hangs when sending a message to the REST API.

I hope you can help. Thanks in advance.
User avatar
radio42
Site Admin
Posts: 8926
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: REST API

Post by radio42 »

If it works on the other computer (it can not be ProppFrexx related), you should check your configuration differences. Maybe a firewall blocking issue?

Regarding the brackets… maybe there is a misunderstanding. You must still send a valid JSON object, eg. an array of commands, which must be denoted by brackets. Each command is then a string (enclosed in quotes) and multiple commands separated by a comma).
Like described here:
viewtopic.php?p=17884#p17884
Or here
viewtopic.php?t=3372
John2103
Posts: 31
Joined: 11 Nov 2019 16:32
Re: REST API

Post by John2103 »

Yes, I know it must be a configuration issue. You were my last hope 😉

I tried a few other things.

• Changed the port to 9000
• Temporarily switched off the Windows firewall
• Ran netsh http add urlacl url=http://+:9000/ user=Everyone

Now when I execute the command netstat -ano | findstr :9000 I get this reply.
TCP 0.0.0.0:9000 0.0.0.0:0 LISTENING 4
TCP [::]:9000 [::]:0 LISTENING 4

When I send a command via Postman (or curl) I get the following reply.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>Service Unavailable</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii">
</HEAD>
<BODY>
<h2>Service Unavailable</h2>
<hr>
<p>HTTP Error 503. The service is unavailable.</p>
</BODY>
</HTML>

Doesn’t that mean that it is not a network issue? After all, The GPIO REST API responds to the request.

The only difference between the old and the new computer is that the old one runs ProppFrexx version 4.4.1.3 and the new one runs version 4.5.1.7
User avatar
radio42
Site Admin
Posts: 8926
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: REST API

Post by radio42 »

Then try to run the old version also on your new PC, then you‘ll see, if that is an issue - ie. simply copy the installation folder.
But I doubt, that this is the issue.
John2103
Posts: 31
Joined: 11 Nov 2019 16:32
Re: REST API

Post by John2103 »

This is really strange. I copied the old version 4.4.1.3 to the new computer and it worked once. After I changed the password in the GPIO client and General Settings, Postman returns a 401 unauthorized message, no matter what password I use (the old or the new).

The new version also has this issue

viewtopic.php?p=20083&hilit=GPIO+client+password#p20083

All of this probably doesn’t make sense. I’ll have to investigate this further.
User avatar
radio42
Site Admin
Posts: 8926
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: REST API

Post by radio42 »

I don’t understand ‚that‘ issue. What issue is it?
The config is saved when you exit the application. But the password is only relevant for the connection between the GPIO client and ProppFrexx OnAir.
Maybe you should reboot your PC? Is there maybe a second process running somewhere in the background?
John2103
Posts: 31
Joined: 11 Nov 2019 16:32
Re: REST API

Post by John2103 »

I realize this is probably a mistake on my part, but it has already cost me a lot of time.
Is paid support on a no cure, no pay basis an option?

Here is some information about the current situation on the new production computer.

The GPIO configuration file:

<add key="RESTAddress" value="http://localhost:8081/" />

gpio.png

When ProppFrexx is not running:

PS C:\Windows\system32> netstat -ano | findstr :8081
PS C:\Windows\system32>

No results from netstat, so port 8081 is free.

When ProppFrexx is running:

PS C:\Windows\system32> netstat -ano | findstr :8081
TCP 0.0.0.0:8081 0.0.0.0:0 LISTENING 4
TCP [::]:8081 [::]:0 LISTENING 4
PS C:\Windows\system32>

Then I run a test with Postman by deliberately sending a wrong password.
As expected, I get a 401 Unauthorized message, which I think proves that the GPIO REST API is responding.

After that, I test again with the correct password, but Postman (or curl) hangs indefinitely.
Debug logging is enabled, but nothing appears in the debug log. When Postman hangs, netstat shows this:

PS C:\Windows\system32> netstat -ano | findstr :8081
TCP 0.0.0.0:8081 0.0.0.0:0 LISTENING 4
TCP [::]:8081 [::]:0 LISTENING 4
TCP [::1]:8081 [::1]:54337 CLOSE_WAIT 4
TCP [::1]:54337 [::1]:8081 FIN_WAIT_2 9832

Here are the Postman settings:
postman.png
User avatar
radio42
Site Admin
Posts: 8926
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: REST API

Post by radio42 »

I am currently on holiday and can not do personal support.
However, you only want to pay for support, if I solve your issue on your hardware and setup?
Even, if it runs fine on another machine?
I am sorry, but this is not an option for me.

Post Reply