Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad Request error from apache server #80

Open
msauer75 opened this issue Jan 2, 2025 · 1 comment
Open

Bad Request error from apache server #80

msauer75 opened this issue Jan 2, 2025 · 1 comment

Comments

@msauer75
Copy link

msauer75 commented Jan 2, 2025

Hi,
I want to use the library in my own Qt/QML project. I want to send a json command to an apache webserver which runs a php script. The script analyzes the method and send an answer.

So I did the following:

sp = new Sp(parent, "http://localhost:84/~martin/gc/rpcJSON.php");

consturctor of Sp:

Sp::Sp(QObject *parent, QString urlArg)
    : QObject {parent}
    , url(QUrl(urlArg))
{
rpcClient = new jcon::JsonRpcTcpClient(parent);
if (!rpcClient->connectToServer(url))
{
qDebug() << ">> SP > (Constructor) \t connecToServer fehlerhaft";
}
auto rpcResult = rpcClient->callAsync("getMaxSp");

QObject::connect(rpcResult.get(), &jcon::JsonRpcRequest::result, this, &Sp::msgRecieved);
QObject::connect(rpcResult.get(), &jcon::JsonRpcRequest::error, this, &Sp::msgError);
}

The library will send the following to the server:

{
    "id": "0fce2d19-6b90-4ff6-ae0d-d45c045a055b",
    "jsonrpc": "2.0",
    "method": "getRandomInt",
    "params": [
        10
    ]
}

But the server will send a 400 bad request error.

What can I do to solve the problem?
Thank you for your help.
BR
martin

@joncol
Copy link
Owner

joncol commented Jan 12, 2025

Hi!

This is kind of difficult to answer without knowing what's going on on the server. It seems that there is something wrong on the server side. Have you tried running your own server with this library (JCON)?

You mention that you're using an Apache web server? Web servers are mostly listening on ports 80 and 443 (for HTTP and HTTPS traffic). This library, and JSON RPC in general, doesn't work over the HTTP protocol, but instead works on a lower layer (TCP or WebSockets protocols as mentioned in the README). Therefore, you have to connect against a server running on a given port with one of those protocols...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants