Unable to send HTTP messages from raspberry pi to the android device

What is the name of the domain?

meriem.uk

What is the issue you’re encountering

I have set up a cloudflare tunnel with my raspberry pi. I would like to send motion sensor data to the android phone app that listens to http://<:/xxxx. I’m able to send messages to the raspberry pi from the app easily but unable to send the motion sensor data to the app. Can someone provide any guidance on where the problem could be?

What steps have you taken to resolve the issue?

my python code: from flask import Flask, request, jsonify

app = Flask(name)

Endpoint to receive prompts from Android on port 8080

@app.route(‘/receive_prompt’, methods=[‘POST’])
def receive_prompt():
data = request.json
prompt = data.get(‘prompt’, ‘’)
print(f"Received prompt: {prompt}")
return jsonify({‘status’: ‘Prompt received’})

Endpoint to send a message to Android on port 8090

@app.route(‘/get_data’, methods=[‘GET’])
def send_message():
response_data = {
‘message’: ‘Server is running!’
}
return jsonify(response_data)

if name == “main”:
# Run the Flask app on port 8080
app.run(host=‘0.0.0.0’, port=8090, threaded=True)

Make sure it’s configured to listen on 127.0.0.1 or localhost instead of 0.0.0.0, add to /etc/hosts as well what’s needed.

Check if app is running on desired ports 8080 or 8090 if proxypassed from Flask/Django via Nginx, with netstat.

May I ask if you’ve already created a tunnel? Do you manage it via Dashboard or locally via CLI? :thinking:

Make sure to enable the NoTLSVerify option (since I am afraid you’re not having an SSL certificate at your Raspberry Pi):

Hi Fritex. thanks for the reply. I have the cloudflare tunnel set up on cloudflare dashboard and not on the CLI. I set up public hotnames http://localhost:8080 and http://localhost:8090. the nginx webserver is working but still can’t get the messages trhough from raspberry pi to the android app. do you have an example on how this can be set up?
Thanks

Could you give it a try with below one, if it would work for you, so you’d just have to adjust some things?:

So it’s working over public hostname?, but messages aren’t coming :thinking:
And you’re not sending them via e.g. WebSockets, correct?
From the code you’ve provided you’re using HTTP request.
Since proxied :orange: , everything goes over 443 via public, despite the routing is done via tunnel and can be over other different port to the inside app.

You get some error while debugging the Android app from Android studio from console output or graddle? Did you changed code in Android maybe?