Second request using QJsonRpcHttpClient always fail.

77 views
Skip to first unread message

bte...@gmail.com

unread,
Jan 17, 2015, 1:37:58 PM1/17/15
to qjsonrpc-d...@googlegroups.com
Hi,
I'm a beginner using QJsonRpc.
I'm trying to use the QJsonRpcHttpClient class, but only the first request to a remote webservice works. I always get QJsonRpcMessage(type=QJsonRpcMessage::Error, id=3, code=-32700, message="unable to process incoming JSON data", data=QJsonValue(string, " ? ") ) after the first one. Follow my code below:


//HEADER
class MSync{
MSync(QObject *parent);
void requestData();

private:
QNetworkAccessManager *manager;
QJsonRpcHttpClient *clientX;
};


//SOURCE
MSync::MSync(QObject *parent) : QObject(parent){
manager=new QNetworkAccessManager(this);
clientX=new QJsonRpcHttpClient(manager,this);
clientX->setEndPoint(MCommon::obj()->getSVCUrl());
}

MSync::requestData(){
QJsonRpcServiceReply *reply = clientX->invokeRemoteMethod("GetData",1,1,"test");
connect(reply, SIGNAL(finished()), this, SLOT(slotRespRequestData()));
}

MSync::slotRespRequestData(){
QJsonRpcServiceReply *reply = static_cast<QJsonRpcServiceReply *>(sender());
if (!reply) {qDebug() << "invalid response received";return;}
QJsonRpcMessage resp= reply->response();
qDebug()<<"resp:"<<resp; //after first request, I always get QJsonRpcMessage(type=QJsonRpcMessage::Error, id=2, code=-32700, message="unable to process incoming JSON data", data=QJsonValue(string, " ? ") )
}

The webservice is working fine everytime. I'm doing something stupid?
Thank you,
Bruno.

Matt Broadstone

unread,
Jan 17, 2015, 3:31:04 PM1/17/15
to bte...@gmail.com, qjsonrpc-d...@googlegroups.com
On Sat, Jan 17, 2015 at 1:37 PM, <bte...@gmail.com> wrote:
Hi,
I'm a beginner using QJsonRpc.

Hey, welcome
 
I'm trying to use the QJsonRpcHttpClient class, but only the first request to a remote webservice works. I always get QJsonRpcMessage(type=QJsonRpcMessage::Error, id=3, code=-32700, message="unable to process incoming JSON data", data=QJsonValue(string, " ? ") ) after the first one. Follow my code below:

Can you please try running your case with QJSONRPC_DEBUG=1 on the command line? This will print a lot of relevant debug information. Also, what web service are you using here, there might be a specific case for different implementations since jsonrpc wasn't truly ever ratified. I just added a test locally to test multiple requests with a shared manager, and it passed just fine

Cheers,
Matt

 

//HEADER
class MSync{
  MSync(QObject *parent);
  void requestData();

private:
  QNetworkAccessManager *manager;
  QJsonRpcHttpClient *clientX;
};


//SOURCE
MSync::MSync(QObject *parent) : QObject(parent){
        manager=new QNetworkAccessManager(this);
        clientX=new QJsonRpcHttpClient(manager,this);
        clientX->setEndPoint(MCommon::obj()->getSVCUrl());
}

MSync::requestData(){
 QJsonRpcServiceReply *reply = clientX->invokeRemoteMethod("GetData",1,1,"test");
 connect(reply, SIGNAL(finished()), this, SLOT(slotRespRequestData()));
}

MSync::slotRespRequestData(){
  QJsonRpcServiceReply *reply = static_cast<QJsonRpcServiceReply *>(sender());
  if (!reply) {qDebug() << "invalid response received";return;}
  QJsonRpcMessage resp= reply->response();
  qDebug()<<"resp:"<<resp; //after first request, I always get QJsonRpcMessage(type=QJsonRpcMessage::Error, id=2, code=-32700, message="unable to process incoming JSON data", data=QJsonValue(string, " ? ") )
}

The webservice is working fine everytime. I'm doing something stupid?
Thank you,
  Bruno.

--
You received this message because you are subscribed to the Google Groups "qjsonrpc-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qjsonrpc-develop...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bruno Tezine

unread,
Jan 17, 2015, 8:17:31 PM1/17/15
to Matt Broadstone, Bruno Tezine, qjsonrpc-d...@googlegroups.com

Hi Matt, thanks for the quick response.
I executed it using QJSONRPC_DEBUG,  but I received no relevant info for this case.
I'm using the latest version of jayrock under .net:
https://code.google.com/p/jayrock/.
I didn't have time to run wireshark on it to confirm if data received is correct. As soon as I test it, I let you know.
Thanks again,
     Bruno

Em 17 de jan de 2015, pelo 6:31 PM, Matt Broadstone <mbro...@gmail.com> escrito:
Reply all
Reply to author
Forward
0 new messages