Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1534

java.net.SocketException - NanoHTTPD (https) - Android

$
0
0

I'm stuck and looked everywhere to find a solution but I think it won't be as effective as getting help from humans haha.
I set up a NanoHTTPD server to listen to https post requests:

public ChargingListener(int port, MainActivity activity) {    super(port);    try {        this.activity = activity;        makeSecure(NanoHTTPD.makeSSLSocketFactory("/keystore.jks", "password".toCharArray()), null);        start(NanoHTTPD.SOCKET_READ_TIMEOUT, false);        logger.info(TAG, "Listener created on port: " + port);    } catch (IOException e) {        logger.error(TAG, "Error creating listener: " + e.getMessage());    }}

When I send a request, I get the following exception (if needed, I can paste the full exception stack):

java.net.SocketException: Socket is closed

The server works normally with http...
BTW, I used the code from a NanoHTTPD guide.

Update:I managed to send a post request with postman and actually received a response, but when I try to send a post request via python requests library, this error rises again.

Solution: By default, postman does not verify self-signed certificates, but python requests does...
Hope this helps someone!


Viewing all articles
Browse latest Browse all 1534

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>