question

NachiketKamat-8641 avatar image
0 Votes"
NachiketKamat-8641 asked karishmatiwari-msft commented

How to allow accessing URLs from service fabric cluster?

I have a python application from which I am trying to connect to couple of URLs.

When I run the application locally then there is no error. When I build a docker image for the application and run it, then also there is no error. However, when I deploy the docker image into a service fabric cluster, then I get the following error. From a similar question, I understand that this may be related to DNS/proxy issues. Can you suggest some steps to fix this in the service fabric cluster?

socket.gaierror: [Errno 11002] getaddrinfo failed

During handling of the above exception, another exception occurred:

urllib.error.URLError:

Code:

 import urllib.request as r
 r.urlopen('https://bootstrap.pypa.io').close()

Traceback:
Traceback (most recent call last):
File "C:\Python\lib\urllib\request.py", line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "C:\Python\lib\http\client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Python\lib\http\client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Python\lib\http\client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Python\lib\http\client.py", line 1026, in _send_output
self.send(msg)
File "C:\Python\lib\http\client.py", line 964, in send
self.connect()
File "C:\Python\lib\http\client.py", line 1392, in connect
super().connect()
File "C:\Python\lib\http\client.py", line 936, in connect
(self.host,self.port), self.timeout, self.source_address)
File "C:\Python\lib\socket.py", line 704, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:\Python\lib\socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11002] getaddrinfo failed

 During handling of the above exception, another exception occurred:
    
 Traceback (most recent call last):
   File "C:\Python\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request
     rv = self.dispatch_request()
   File "C:\Python\lib\site-packages\flask\app.py", line 1799, in dispatch_request
     return self.view_functions[rule.endpoint](**req.view_args)
   File "C:\app\email_extractor\__init__.py", line 106, in hello_test
     r.urlopen('https://bootstrap.pypa.io').close()
   File "C:\Python\lib\urllib\request.py", line 223, in urlopen
     return opener.open(url, data, timeout)
   File "C:\Python\lib\urllib\request.py", line 526, in open
     response = self._open(req, data)
   File "C:\Python\lib\urllib\request.py", line 544, in _open
     '_open', req)
   File "C:\Python\lib\urllib\request.py", line 504, in _call_chain
     result = func(*args)
   File "C:\Python\lib\urllib\request.py", line 1361, in https_open
     context=self._context, check_hostname=self._check_hostname)
   File "C:\Python\lib\urllib\request.py", line 1320, in do_open
     raise URLError(err)
 urllib.error.URLError:  















service-fabric-standalone
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

If the response did help in answering your query, please 'Accept as answer', so that it helps other users visiting the forum.

0 Votes 0 ·

1 Answer

NandanMathure avatar image
1 Vote"
NandanMathure answered

Hi,

This may be happening because the URL is cluster URL and docker image is running on only one of the nodes.

Either run docker image on all nodes or configure reverse proxy (https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-reverseproxy) to allow external traffic be routed to correct node.

Also, try to access URL of node directly to make sure firewalls are not blocking the traffic on specific ports.

Thanks

Nandan Mathure

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.