Problem with JSON RPC on RPI and calling a method
up vote
0
down vote
favorite
I got a raspberry pi with a json rpc server running on it. i used this module: https://github.com/bcb/jsonrpcserver
Everything is working fine when I only make a request to the following method:
@method
def ping():
return "pong"
But when I want to go further and do other functions and things like
@method
def changeDisplay():
self.led.clear_display()
Even when I do
@method
def ping():
self.helloworld()
def helloworld():
print("helloworld")
then I get a 500 error without further explanation.
request("http://192.168.2.5:5000", "ping")
Request looks like above I am stuck and have tried many different things.
Traceback:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesjsonrpcclient__init__.py", line 8, in request
return HTTPClient(endpoint).request(*args, **kwargs)
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesapply_defaultsdecorators.py", line 13, in wrapper
return function(self, *args, **kwargs)
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesjsonrpcclientclient.py", line 232, in request
validate_against_schema=validate_against_schema,
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesapply_defaultsdecorators.py", line 13, in wrapper
return function(self, *args, **kwargs)
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesjsonrpcclientclient.py", line 171, in send
self.validate_response(response)
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesjsonrpcclientclientshttp_client.py", line 48, in validate_response
raise ReceivedNon2xxResponseError(response.raw.status_code)
jsonrpcclient.exceptions.ReceivedNon2xxResponseError: Received 500 status code
Pastebin of full code:
https://pastebin.com/dgFEUBNp
UPDATE
Think it has something to do with the server not being async. All prints after server start are not printed
python request raspberry-pi raspberry-pi3 json-rpc
|
show 7 more comments
up vote
0
down vote
favorite
I got a raspberry pi with a json rpc server running on it. i used this module: https://github.com/bcb/jsonrpcserver
Everything is working fine when I only make a request to the following method:
@method
def ping():
return "pong"
But when I want to go further and do other functions and things like
@method
def changeDisplay():
self.led.clear_display()
Even when I do
@method
def ping():
self.helloworld()
def helloworld():
print("helloworld")
then I get a 500 error without further explanation.
request("http://192.168.2.5:5000", "ping")
Request looks like above I am stuck and have tried many different things.
Traceback:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesjsonrpcclient__init__.py", line 8, in request
return HTTPClient(endpoint).request(*args, **kwargs)
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesapply_defaultsdecorators.py", line 13, in wrapper
return function(self, *args, **kwargs)
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesjsonrpcclientclient.py", line 232, in request
validate_against_schema=validate_against_schema,
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesapply_defaultsdecorators.py", line 13, in wrapper
return function(self, *args, **kwargs)
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesjsonrpcclientclient.py", line 171, in send
self.validate_response(response)
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesjsonrpcclientclientshttp_client.py", line 48, in validate_response
raise ReceivedNon2xxResponseError(response.raw.status_code)
jsonrpcclient.exceptions.ReceivedNon2xxResponseError: Received 500 status code
Pastebin of full code:
https://pastebin.com/dgFEUBNp
UPDATE
Think it has something to do with the server not being async. All prints after server start are not printed
python request raspberry-pi raspberry-pi3 json-rpc
1
what is the request function? is it python requests?
– Jack Herer
Nov 11 at 10:16
1
It's a python request indeed. (from jsonrpcclient import request)
– tijn167
Nov 11 at 10:19
1
I meant the python requests module not a function from jsonrpcclient, but now I know, its most likely a 500 error is given because whichever function you are calling e.g.self.led.clear_display()
is failing.
– Jack Herer
Nov 11 at 10:22
1
Made an edit. It's not in the function, because even a simple hello world which prints it is not working.
– tijn167
Nov 11 at 10:26
1
whats the traceback?
– Jack Herer
Nov 11 at 10:27
|
show 7 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I got a raspberry pi with a json rpc server running on it. i used this module: https://github.com/bcb/jsonrpcserver
Everything is working fine when I only make a request to the following method:
@method
def ping():
return "pong"
But when I want to go further and do other functions and things like
@method
def changeDisplay():
self.led.clear_display()
Even when I do
@method
def ping():
self.helloworld()
def helloworld():
print("helloworld")
then I get a 500 error without further explanation.
request("http://192.168.2.5:5000", "ping")
Request looks like above I am stuck and have tried many different things.
Traceback:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesjsonrpcclient__init__.py", line 8, in request
return HTTPClient(endpoint).request(*args, **kwargs)
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesapply_defaultsdecorators.py", line 13, in wrapper
return function(self, *args, **kwargs)
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesjsonrpcclientclient.py", line 232, in request
validate_against_schema=validate_against_schema,
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesapply_defaultsdecorators.py", line 13, in wrapper
return function(self, *args, **kwargs)
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesjsonrpcclientclient.py", line 171, in send
self.validate_response(response)
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesjsonrpcclientclientshttp_client.py", line 48, in validate_response
raise ReceivedNon2xxResponseError(response.raw.status_code)
jsonrpcclient.exceptions.ReceivedNon2xxResponseError: Received 500 status code
Pastebin of full code:
https://pastebin.com/dgFEUBNp
UPDATE
Think it has something to do with the server not being async. All prints after server start are not printed
python request raspberry-pi raspberry-pi3 json-rpc
I got a raspberry pi with a json rpc server running on it. i used this module: https://github.com/bcb/jsonrpcserver
Everything is working fine when I only make a request to the following method:
@method
def ping():
return "pong"
But when I want to go further and do other functions and things like
@method
def changeDisplay():
self.led.clear_display()
Even when I do
@method
def ping():
self.helloworld()
def helloworld():
print("helloworld")
then I get a 500 error without further explanation.
request("http://192.168.2.5:5000", "ping")
Request looks like above I am stuck and have tried many different things.
Traceback:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesjsonrpcclient__init__.py", line 8, in request
return HTTPClient(endpoint).request(*args, **kwargs)
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesapply_defaultsdecorators.py", line 13, in wrapper
return function(self, *args, **kwargs)
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesjsonrpcclientclient.py", line 232, in request
validate_against_schema=validate_against_schema,
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesapply_defaultsdecorators.py", line 13, in wrapper
return function(self, *args, **kwargs)
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesjsonrpcclientclient.py", line 171, in send
self.validate_response(response)
File "C:UsersTijnPycharmProjectsJSONrpcTestvenvlibsite-packagesjsonrpcclientclientshttp_client.py", line 48, in validate_response
raise ReceivedNon2xxResponseError(response.raw.status_code)
jsonrpcclient.exceptions.ReceivedNon2xxResponseError: Received 500 status code
Pastebin of full code:
https://pastebin.com/dgFEUBNp
UPDATE
Think it has something to do with the server not being async. All prints after server start are not printed
python request raspberry-pi raspberry-pi3 json-rpc
python request raspberry-pi raspberry-pi3 json-rpc
edited Nov 11 at 13:02
asked Nov 11 at 10:03
tijn167
239
239
1
what is the request function? is it python requests?
– Jack Herer
Nov 11 at 10:16
1
It's a python request indeed. (from jsonrpcclient import request)
– tijn167
Nov 11 at 10:19
1
I meant the python requests module not a function from jsonrpcclient, but now I know, its most likely a 500 error is given because whichever function you are calling e.g.self.led.clear_display()
is failing.
– Jack Herer
Nov 11 at 10:22
1
Made an edit. It's not in the function, because even a simple hello world which prints it is not working.
– tijn167
Nov 11 at 10:26
1
whats the traceback?
– Jack Herer
Nov 11 at 10:27
|
show 7 more comments
1
what is the request function? is it python requests?
– Jack Herer
Nov 11 at 10:16
1
It's a python request indeed. (from jsonrpcclient import request)
– tijn167
Nov 11 at 10:19
1
I meant the python requests module not a function from jsonrpcclient, but now I know, its most likely a 500 error is given because whichever function you are calling e.g.self.led.clear_display()
is failing.
– Jack Herer
Nov 11 at 10:22
1
Made an edit. It's not in the function, because even a simple hello world which prints it is not working.
– tijn167
Nov 11 at 10:26
1
whats the traceback?
– Jack Herer
Nov 11 at 10:27
1
1
what is the request function? is it python requests?
– Jack Herer
Nov 11 at 10:16
what is the request function? is it python requests?
– Jack Herer
Nov 11 at 10:16
1
1
It's a python request indeed. (from jsonrpcclient import request)
– tijn167
Nov 11 at 10:19
It's a python request indeed. (from jsonrpcclient import request)
– tijn167
Nov 11 at 10:19
1
1
I meant the python requests module not a function from jsonrpcclient, but now I know, its most likely a 500 error is given because whichever function you are calling e.g.
self.led.clear_display()
is failing.– Jack Herer
Nov 11 at 10:22
I meant the python requests module not a function from jsonrpcclient, but now I know, its most likely a 500 error is given because whichever function you are calling e.g.
self.led.clear_display()
is failing.– Jack Herer
Nov 11 at 10:22
1
1
Made an edit. It's not in the function, because even a simple hello world which prints it is not working.
– tijn167
Nov 11 at 10:26
Made an edit. It's not in the function, because even a simple hello world which prints it is not working.
– tijn167
Nov 11 at 10:26
1
1
whats the traceback?
– Jack Herer
Nov 11 at 10:27
whats the traceback?
– Jack Herer
Nov 11 at 10:27
|
show 7 more comments
1 Answer
1
active
oldest
votes
up vote
1
down vote
The methods of your class do not receive a self
parameter, yet attempt to use it:
class Bartender(MenuDelegate):
...
@method
def ping():
self.changeDsplay() # name `self` is not defined
print (" TOkm")
return " ewa"
The docs for jsonrpcserver
and the source do not suggest that method
can properly handle classes and their methods. It seems that you have to add the bound methods an instance, not the unbound methods of the class.
class Bartender(MenuDelegate):
...
# regular unbound method taking `self` parameter
def ping(self):
self.changeDsplay()
print (" TOkm")
return " ewa"
def run(self):
# register bound methods *of this instance*
method(ping=self.ping)
...
Sorry, was a tryout. In my original code ping did receive a self param. Only difference is that it outputs a 400 error
– tijn167
Nov 11 at 13:18
@tijn167 Neither the code on pastebin nor in your answer show that. Please post your actual code! Also take a look at the registration of bound methods I added.
– MisterMiyagi
Nov 11 at 13:19
Tried your method, still nothing changed. Think it has something to do with using non async. Because everything after server start isn't executed
– tijn167
Nov 11 at 14:12
Your method did in fact work with a little tweak. I also started the server in the run method and thats what did the job. Now just got too check if the physical and mobile work together. Thanks!
– tijn167
Nov 11 at 14:37
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
The methods of your class do not receive a self
parameter, yet attempt to use it:
class Bartender(MenuDelegate):
...
@method
def ping():
self.changeDsplay() # name `self` is not defined
print (" TOkm")
return " ewa"
The docs for jsonrpcserver
and the source do not suggest that method
can properly handle classes and their methods. It seems that you have to add the bound methods an instance, not the unbound methods of the class.
class Bartender(MenuDelegate):
...
# regular unbound method taking `self` parameter
def ping(self):
self.changeDsplay()
print (" TOkm")
return " ewa"
def run(self):
# register bound methods *of this instance*
method(ping=self.ping)
...
Sorry, was a tryout. In my original code ping did receive a self param. Only difference is that it outputs a 400 error
– tijn167
Nov 11 at 13:18
@tijn167 Neither the code on pastebin nor in your answer show that. Please post your actual code! Also take a look at the registration of bound methods I added.
– MisterMiyagi
Nov 11 at 13:19
Tried your method, still nothing changed. Think it has something to do with using non async. Because everything after server start isn't executed
– tijn167
Nov 11 at 14:12
Your method did in fact work with a little tweak. I also started the server in the run method and thats what did the job. Now just got too check if the physical and mobile work together. Thanks!
– tijn167
Nov 11 at 14:37
add a comment |
up vote
1
down vote
The methods of your class do not receive a self
parameter, yet attempt to use it:
class Bartender(MenuDelegate):
...
@method
def ping():
self.changeDsplay() # name `self` is not defined
print (" TOkm")
return " ewa"
The docs for jsonrpcserver
and the source do not suggest that method
can properly handle classes and their methods. It seems that you have to add the bound methods an instance, not the unbound methods of the class.
class Bartender(MenuDelegate):
...
# regular unbound method taking `self` parameter
def ping(self):
self.changeDsplay()
print (" TOkm")
return " ewa"
def run(self):
# register bound methods *of this instance*
method(ping=self.ping)
...
Sorry, was a tryout. In my original code ping did receive a self param. Only difference is that it outputs a 400 error
– tijn167
Nov 11 at 13:18
@tijn167 Neither the code on pastebin nor in your answer show that. Please post your actual code! Also take a look at the registration of bound methods I added.
– MisterMiyagi
Nov 11 at 13:19
Tried your method, still nothing changed. Think it has something to do with using non async. Because everything after server start isn't executed
– tijn167
Nov 11 at 14:12
Your method did in fact work with a little tweak. I also started the server in the run method and thats what did the job. Now just got too check if the physical and mobile work together. Thanks!
– tijn167
Nov 11 at 14:37
add a comment |
up vote
1
down vote
up vote
1
down vote
The methods of your class do not receive a self
parameter, yet attempt to use it:
class Bartender(MenuDelegate):
...
@method
def ping():
self.changeDsplay() # name `self` is not defined
print (" TOkm")
return " ewa"
The docs for jsonrpcserver
and the source do not suggest that method
can properly handle classes and their methods. It seems that you have to add the bound methods an instance, not the unbound methods of the class.
class Bartender(MenuDelegate):
...
# regular unbound method taking `self` parameter
def ping(self):
self.changeDsplay()
print (" TOkm")
return " ewa"
def run(self):
# register bound methods *of this instance*
method(ping=self.ping)
...
The methods of your class do not receive a self
parameter, yet attempt to use it:
class Bartender(MenuDelegate):
...
@method
def ping():
self.changeDsplay() # name `self` is not defined
print (" TOkm")
return " ewa"
The docs for jsonrpcserver
and the source do not suggest that method
can properly handle classes and their methods. It seems that you have to add the bound methods an instance, not the unbound methods of the class.
class Bartender(MenuDelegate):
...
# regular unbound method taking `self` parameter
def ping(self):
self.changeDsplay()
print (" TOkm")
return " ewa"
def run(self):
# register bound methods *of this instance*
method(ping=self.ping)
...
edited Nov 11 at 13:18
answered Nov 11 at 13:08
MisterMiyagi
7,2142040
7,2142040
Sorry, was a tryout. In my original code ping did receive a self param. Only difference is that it outputs a 400 error
– tijn167
Nov 11 at 13:18
@tijn167 Neither the code on pastebin nor in your answer show that. Please post your actual code! Also take a look at the registration of bound methods I added.
– MisterMiyagi
Nov 11 at 13:19
Tried your method, still nothing changed. Think it has something to do with using non async. Because everything after server start isn't executed
– tijn167
Nov 11 at 14:12
Your method did in fact work with a little tweak. I also started the server in the run method and thats what did the job. Now just got too check if the physical and mobile work together. Thanks!
– tijn167
Nov 11 at 14:37
add a comment |
Sorry, was a tryout. In my original code ping did receive a self param. Only difference is that it outputs a 400 error
– tijn167
Nov 11 at 13:18
@tijn167 Neither the code on pastebin nor in your answer show that. Please post your actual code! Also take a look at the registration of bound methods I added.
– MisterMiyagi
Nov 11 at 13:19
Tried your method, still nothing changed. Think it has something to do with using non async. Because everything after server start isn't executed
– tijn167
Nov 11 at 14:12
Your method did in fact work with a little tweak. I also started the server in the run method and thats what did the job. Now just got too check if the physical and mobile work together. Thanks!
– tijn167
Nov 11 at 14:37
Sorry, was a tryout. In my original code ping did receive a self param. Only difference is that it outputs a 400 error
– tijn167
Nov 11 at 13:18
Sorry, was a tryout. In my original code ping did receive a self param. Only difference is that it outputs a 400 error
– tijn167
Nov 11 at 13:18
@tijn167 Neither the code on pastebin nor in your answer show that. Please post your actual code! Also take a look at the registration of bound methods I added.
– MisterMiyagi
Nov 11 at 13:19
@tijn167 Neither the code on pastebin nor in your answer show that. Please post your actual code! Also take a look at the registration of bound methods I added.
– MisterMiyagi
Nov 11 at 13:19
Tried your method, still nothing changed. Think it has something to do with using non async. Because everything after server start isn't executed
– tijn167
Nov 11 at 14:12
Tried your method, still nothing changed. Think it has something to do with using non async. Because everything after server start isn't executed
– tijn167
Nov 11 at 14:12
Your method did in fact work with a little tweak. I also started the server in the run method and thats what did the job. Now just got too check if the physical and mobile work together. Thanks!
– tijn167
Nov 11 at 14:37
Your method did in fact work with a little tweak. I also started the server in the run method and thats what did the job. Now just got too check if the physical and mobile work together. Thanks!
– tijn167
Nov 11 at 14:37
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247618%2fproblem-with-json-rpc-on-rpi-and-calling-a-method%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
what is the request function? is it python requests?
– Jack Herer
Nov 11 at 10:16
1
It's a python request indeed. (from jsonrpcclient import request)
– tijn167
Nov 11 at 10:19
1
I meant the python requests module not a function from jsonrpcclient, but now I know, its most likely a 500 error is given because whichever function you are calling e.g.
self.led.clear_display()
is failing.– Jack Herer
Nov 11 at 10:22
1
Made an edit. It's not in the function, because even a simple hello world which prints it is not working.
– tijn167
Nov 11 at 10:26
1
whats the traceback?
– Jack Herer
Nov 11 at 10:27