SimpleProxy throws intermitent error when connecting to web2py webservice through https

20 views
Skip to first unread message

Lisandro

unread,
Sep 25, 2016, 5:27:35 PM9/25/16
to web2py-users
Hi there!
I've a jsonrpc webservice built with web2py, it's been running for several months.
Today we added SSL to the domain that serves the app running the webservice.

Since that change, I can still connect and use the webservice, but I have an intermitent error "[Errno 111] Connection refused".
This is the error traceback:

Traceback (most recent call last): File "/var/www/medios/gluon/restricted.py", line 227, in restricted exec ccode in environment File "/var/www/medios/applications/webmedios/controllers/ws.py", line 300, in File "/var/www/medios/gluon/globals.py", line 393, in self._caller = lambda f: f() File "/var/www/medios/applications/webmedios/controllers/ws.py", line 10, in call return service() File "/var/www/medios/gluon/tools.py", line 5132, in __call__ return self.serve_jsonrpc() File "/var/www/medios/gluon/tools.py", line 4852, in serve_jsonrpc data = json_parser.loads(request.body.read()) File "/usr/lib/python2.7/json/__init__.py", line 338, in loads return _default_decoder.decode(s) File "/usr/lib/python2.7/json/decoder.py", line 366, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode raise ValueError("No JSON object could be decoded") ValueError: No JSON object could be decoded



The webservice is defined in ws.py controller like this:

from gluon.tools import Service

service
= Service()


def call():
    session
.forget()
   
return service()


@service.jsonrpc
def test(_vars):
   
return {'success': True}



Then, I use the webservice like this:

def consume_test():
   
from gluon.contrib.simplejsonrpc import ServerProxy
    webservice
= ServerProxy('https://mydomain.com/ws/call/jsonrpc')  # notice it uses https
    result
= webservice.test('whatever')
   
return result



I can confirm that the app that runs the webservice is navigable through https with no problem at all.
Do I need to connect to the webservice in a special way for https? What else could be the problem?


Thanks in advance!
Regards,
Lisandro.

Lisandro

unread,
Sep 25, 2016, 6:59:45 PM9/25/16
to web2py-users
I've found out that it has nothing to do with https.
I've tried to connect to the webserver from my local computer (using a similar python app), and I can successfully connect.

I think the problem may be in some python library, because now I remember that today I've updated packages on my server (where the error is being throwed).

Can anyone point me in some direction? 
I'm pretty lost here. Some python library has been updated and it isn't working properly, but I don't know how to find the problem :/

Lisandro

unread,
Sep 25, 2016, 9:57:46 PM9/25/16
to web2py-users
I've found the problem, and it was much simplier than expected.

For some strange reason, my server was resolving incorrect IP adress for my domain. The IP was changed yesterday, and changes have been propagated. However, from inside my server, if I ping the domain, I still get the old IP. I've already contacted my server provider to solve this. In the meanwhile, I just added the correct IP/domain to /etc/hosts and problem solved.

Sorry for the bother!
Reply all
Reply to author
Forward
0 new messages