遇到以下错误: [WinError 10061]无法建立连接,因为目标计算机主动拒绝它。 确认服务已经开始,服务方面没有问题。 如果我直接运行如下代码,则不会出现错误:
Class Test(testContainer):
restcall = "http://localhost:8086/service/records/all"
def__int__(self):
#service is started in init,
...
def restCallTest(self):
getRecordsUrl = "http://localhost:8086/service/records/all"
try:
allRecordsResponse = urlopen(getRecordsUrl)
except URLError as e:
print(e.reason)
return allRecordsResponse
def test(self):
response = urlopen(self.restCall)
但如果我通过在Test中调用restCallTest来运行如下,则会有WinError 10061
Class Test(testContainer):
restcall = "http://localhost:8086/service/records/all"
def__int__(self):
#service is started in init,
...
def restCallTest(self):
getRecordsUrl = "http://localhost:8086/service/records/all"
try:
allRecordsResponse = urlopen(getRecordsUrl)
except URLError as e:
print(e.reason)
return allRecordsResponse
def test(self):
response = self.restCallTest()