[Solved] "Send request to server / API / web page" does not work in the exported application on android phone

I have a working local web server, I tested it with the preview in GDevelop5, everything worked, the answer came and was recorded, but when I decided to export the application to android, the answers stopped coming (from the web server) in the browser on the computer everything works, there is an answer, there is also a response from the server in the preview in where the developer is and it is written to the Text variable, it works in the browser on the phone, but in the exported application - no, I hope if I did something wrong, they will help me, or if this bug will be fixed …
Google Photos
this is a browser on pc
Google Photos
this is a preview in gdevelop5
Google Photos
this is a request event
Google Photos
these are scene events
Google Photos
this is the browser on the phone (android)

and this is a mobile application on android, you can notice that instead of the expected response from the 12345 server, we see 0.
the red squares in the screenshots indicate a response from the server.

Try to move the modify text action in a separate event, with a condition to wait until the data has been received (the variable has changed).
Also, you can probably check the logs of your web server to confirm that the GET request is received.

I did everything as you advised - it does not work, the server does not accept the request, and therefore cannot give an answer, I also checked POST, similarly.

Always show updated screenshot of the events sheet, please :blush:

What do you mean by accept? Receive or accept?
If the request is denied, it might be a setting problem with your server.
What does the error variable say?

Hmm, it’s not on your screenshot. I’m looking at this action:
And you?

Is it possible your mobile device is using mobile data when using the exported version of the game?

It may be using local wifi in the browser version and mobile data in the exported version… whether that’s an issue with the phone settings or gdevelop I can’t say, but if your phone is using mobile data it will not be able to contact the server on your local network unless you’ve configured port forwarding/RDNS at your gateway/router.

I recommend you go into airplane mode/deactivate your phone’s data, make sure that your only connection is wifi and test again. Another possibility would be to set up your system on a free webhost and see it runs.

Also, you might want to use HTTPS for the server connection. This is a similar issue I was having a while back and it required to use HTTPS for sending/getting data from a server.

1 Like

Google Photos
Google Photos
1.Where and how to view the error variable?
2.POST is written to .txt so I understand that the parameter came, when I send from the phone, nothing happens, my server is working correctly, the error is either in my code in the GD or in the GD itself

Just checked, the problem is not in the mobile connection and not in the wi-fi, + I forwarded the port

Looking at your events you have no variable storing the response, it looks like just double quotes (""). The error message is stored in the variable “Text”. To view the error message use a text object and set its value to VariableString(Text).

Jurfix1 you might wanna try to debug the app using chrome on your PC. You can find details on how to do that if you google for “debug cordova with chrome”. This is a link I found: How to debug a cordova app on your device with Google Chrome | Our Code World. The advantage if that you get to see exactly what is the problem.

I still suspect you need to use HTTPS. Any change you can do a quick test with HTTPS on the server?

Google Photos

Variable error say(on the phone): [object ProgressEvent]

the first screenshot was in version 93, because of this I got a little disoriented

Will it work with a self-signed ssl key?

I don’t think so, because you have to accept the certificate to that server before you try to connect through the cordova app. If the server is available on the internet, you could try to get a free certificate from here: https://letsencrypt.org/

1 Like

I’m trying, I’m pretty sure the problem is in the protocol.

I’m pretty sure the problem is the https restriction on the android platform. I had this issue which I was able to identify using chrome and remote debugging.

1 Like

you can also use certbot as a CLI to get a ssl issued to the server, but you may need a domain name to get it issued.

You can try a free RDNS provider, such as afraid.org or noip to get a domain for your home server.

There’s also several free server admin tools that can facilitate the setup process for hostname + http + ssl, such as webmin or cyberpanel.

Hello everyone, the problem was solved, it was that the exported application to the android did not send the http request, the decision to transfer the server to https, thank you all, you can close the topic, I also recommend that the GD team make edits to the wiki about the network, stating that the http does not work on phone, thanks.

I have the same problem, error is [object ProgressEvent],
but I am using https server. Any ideas ?

I did a little investigation - this is a bug.