Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Android XMLHttpRequest doesn't work



  • Hello
    I add openssl libs to my project and sslsocket work fine. Included precompile libs KDAB

    SSLSOCKET connected to host: fztest
    SSLSOCKET Authentication:		RSA
    SSLSOCKET Encryption:		AESGCM(256)
    SSLSOCKET Key Exchange:		ECDH
    SSLSOCKET Cipher Name:		ECDHE-RSA-AES256-GCM-SHA384
    SSLSOCKET Protocol:		TLSv1.2
    SSLSOCKET encrypted
    SSLSOCKET handshake
    SSLSOCKET SSL support: true
    SSLSOCKET SSL version used for build: OpenSSL 1.1.1d  10 Sep 2019
    SSLSOCKET SSL version used for run-time: 269488207
    SSLSOCKET write:
    POST /Test.v2/REST/GetServerTime HTTP/1.1
    Connection: Keep-Alive
    Content-Type: application/json
    Host: fztest
    Content-length: 2
    SSLSOCKET bytes written: 151
    SSLSOCKET onReadyRead
    SSLSOCKET read finished
    SSLSOCKET post ended
    SSLSOCKET readAll:
    {"value":"29.03.2020 12:48:04","errorCode":0,"errorString":null}
    

    But when I send request from js by XMLHttpRequest I got the status of request 0
    With http it's work good.

    "NETWORK_HANDLER POST https://ecom.lan/list started..."
    "NETWORK_HANDLER sent"
    "NETWORK_HANDLER status: 0"
    "NETWORK_HANDLER response received:"
    

    QT 5.12.7
    Platform Android

    What i have missed?
    Thanks


  • Lifetime Qt Champion

    Hi,

    Are you deploying the OpenSSL libraries with your application ?



  • Thank you for replaying.

    What do you mean?
    The libs are added to project.

    Screenshot 2020-03-29 at 16.43.24.png


  • Lifetime Qt Champion

    Does it work properly if you execute your application in your development machine ?



  • I found where was problem.
    Add code below before sslsocket init and its work fine with XMLHttpRequest for https.

    QSslConfiguration config = QSslConfiguration::defaultConfiguration();
        config.setPeerVerifyMode(QSslSocket::QueryPeer);
        QSslConfiguration::setDefaultConfiguration(config);
    

    Good luck


Log in to reply