-
Notifications
You must be signed in to change notification settings - Fork 17
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
OS Error: [WinError 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted #14
Comments
Hello, I've been testing it a while and it seems to be a server side problem. When too many requests are done in a brief period of time, server refuses the connection. It is a security setting in the server side, which maybe could be disabled when IPC server is meant to be used locally. Meanwhile, in the client side, user can catch the error and sleep the execution to avoid this problem: import unittest
import olca
import uuid
import time
import requests
class TestClientConnection(unittest.TestCase):
def setUp(self):
self.client = olca.Client(8080)
self.test_flow = olca.Flow()
self.test_flow.id = str(uuid.uuid4())
self.test_flow.flow_type = olca.FlowType.PRODUCT_FLOW
self.test_flow.name = "Test Flow"
self.test_flow.description = "Added from the olca-ipc python API..."
mass = self.client.find(olca.FlowProperty, 'Mass')
mass_factor = olca.FlowPropertyFactor()
mass_factor.conversion_factor = 1.0
mass_factor.flow_property = mass
mass_factor.reference_flow_property = True
self.test_flow.flow_properties = [mass_factor]
def test_multiple_connections(self):
for i in range(15000):
with self.subTest(i=i):
try:
self.client.insert(self.test_flow)
response = self.client.delete(self.test_flow)
except requests.exceptions.ConnectionError:
print('Letting server rest...')
time.sleep(30)
self.client.insert(self.test_flow)
response = self.client.delete(self.test_flow)
print(i, response)
self.assertEqual(response, 'ok')
if __name__ == '__main__':
unittest.main() This test is completed without errors. |
Hello @Miguel-g-c, Ran 1 test in 4.080s FAILED (errors=1) The error hints are,
|
Hi @yvechang, Can you translate this: for i in range(15000):
self.client.insert(self.test_flow)
response = self.client.delete(self.test_flow)
time.sleep(1)
self.assertEqual(response, 'ok') |
"無法連線,因為目標電腦拒絕連線" means >> No connection could be made because the target machine actively refused it |
Hello @Miguel-g-c, I had tried your suggestion, but no matter sleep(1), sleep(10) or sleep(100), I got the same fault. Thank you. |
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connection.py", line 160, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\util\connection.py", line 84, in create_connection
raise err
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\util\connection.py", line 74, in create_connection
sock.connect(sa)
OSError: [WinError 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted
I'm getting this OSError with IPC when i am performing many calls to the client. I am cleaning a database in olca 1.10.3 by deleting unused FedEFL flows, with client.delete(Flow). I will get this error after several thousand successful calls.
The text was updated successfully, but these errors were encountered: