Re: Problem with pl/python procedure connecting to the internet - Mailing list pgsql-general

From Charles Clavadetscher
Subject Re: Problem with pl/python procedure connecting to the internet
Date
Msg-id 018e01d0dd79$7bed6080$73c82180$@swisspug.org
Whole thread Raw
In response to Re: Problem with pl/python procedure connecting to the internet  (Igor Sosa Mayor <joseleopoldo1792@gmail.com>)
List pgsql-general
Hi

Weird. According to
http://geopy.readthedocs.org/en/latest/#geopy.exc.GeocoderServiceError this
is the most generic exception, only used when there is not a more specific
one (which include by the way problems caused by connectivity and
authorization). The message of the exception is supposed to be the one
delivered by the original application. In this case: "Nombre o servicio
desconocido":

I am wondering if there is an error message matching the one you receive in
PostgreSQL.

> > Are you sure that you really use exactly the same code? The indication
> > "survice unknown" seems to point to an error in the URL and not to an
> > authorization problem. Maybe some encoding problem?
>
> THnaks for your hints.
>
> Yes, exactly the same code. Exactly the same query: two consoles, one with
> postgres, other with ipython. Postgres gives the error; ipython works.

Somehow I expected that answer. I am not a python expert, but it happens
that different pieces of code at the end do not use the same libraries or
framework code by configuration. But if you are positive on that, no more
discussion.

> > The irritating thing is that you mention that it works sometimes and
> > sometimes not. Getting back to the encoding problem idea, is there a
> > difference if you call the function with a name containing special
> > characters (e.g. "é", "à", "ñ") or not?
>
> No special characters in the query. To be honest: it worked only 2-3 times
at
> work and I thought 'finally I managed to do it work'. But since then, it
is not
> working anymore...

Well, if it worked a few times and then never again, then something must
have changed in your system. This could also be a possible reason for the
error.
Sorry for asking obvious things, but it happened to me to oversee some of
them in the past: Are you making the calls from the same computer?

> In any case: I'm pretty sure it is a problem of postgres which is not able
to
> make the connection. If I put a parameter timeout=15, postgres gives
> immediately the same error.

So it looks like a timeout problem with a confusing error message.
A possible way to follow this up would be to call another webservice from a
python function in PG and see if it behaves the same.
Another way to analyze the problem could be to sniff the network traffic and
see what really happens when you make the function call. This could help at
least to discard network problems and may lead to some useful information.

I hope that you will find a solution.
Bye
Charles




pgsql-general by date:

Previous
From: Igor Sosa Mayor
Date:
Subject: Re: Problem with pl/python procedure connecting to the internet
Next
From: Martín Marqués
Date:
Subject: Re: master/master replication with load balancer in front