Computers are rife with potential errors and, of all of them, socket error 10054 is one of the easier ones to fix. This error is usually caused accidentally when the user shuts down the software or closes the connection while the computer is attempting to connect with a server. More serious causes of this error are the Internet connection suddenly dropping or a proxy server disabling server connections. As with all errors, the firewall also could be acting up and causing the connection to break.
The overall reason why this socket error occurs is because the server connection has been broken by something outside the server. Most of the time, this is an action caused, either purposefully or accidentally, by the user. When 10054 manifests, as with other errors, the first thing that the user should do is to temporarily disable the firewall, because firewalls sometimes break good connections, thinking they are bad.
If the problem occurred because of an accidental or manual shutdown of the program, then this will be even easier to fix than the firewall method. Sometimes, when a user is attempting to connect to a server, he or she will close the program. This may be because he no longer needs to connect to the server or because the program was closed mistakenly. In this instance, he can just start the program again and the connection should work.
A break in the Internet connection also can cause a socket error 10054. As with the program, this can occur manually. If the user is not at fault for breaking the Internet connection, he should check the modem, router, and any internal device connecting to the Internet to ensure they are working. Manually resetting the device and calling the Internet service provider (ISP) can help get the Internet back online. In more serious cases, the device may have to be repaired or replaced.
Another reason for this error is that the user is using a proxy server to mask his computer address. This happens if the server is attempting to connect to the computer’s inherent address, and not the proxy server. If this occurs, the user can manually tell the server to connect to the proxy and not directly to the computer. Otherwise, the connection will keep breaking.
Hello,
I’ve been following the quickstart tutorial on the Azure help docs (a simple ASP.NET MVC app, using the default template). However, I created the Web Service resource myself via the Azure portal and when I configured the publish settings in Visual Studio
I chose «Choose Existing» instead of «Create New» (however I have also tried doing the create new option with the same error encountered).
When I hit publish everything seems to be working, but eventually I get the following:
«`
F:Microsoft Visual Studio2017CommunityMSBuildMicrosoftVisualStudiov15.0WebMicrosoft.Web.Publishing.targets(4292,5): Warning : Retrying the sync because a socket error (10054) occurred.
Retrying operation ‘Serialization’ on object sitemanifest (sourcePath). Attempt 1 of 10.
«`
Eventually the whole thing fails and I have to try again. I haven’t been able to find a solution to this yet. I’ve see some answers that suggest a firewall issue on the server I’m deploying to, but I don’t think I have access to that since I set up the resource
as a Web App on Azure (not using a VM that I setup).
I’ve also seen some people suggest that it may be an issue with my ISP, but I’m just trying to exhaust all my options before I get on the phone with them.
Does anyone know of this issue or know of any workarounds?
edit:
Just waited out all of the timeouts and got an error in a log file:
«`
11/13/2018 1:28:28 PM
System.AggregateException: One or more errors occurred. —> System.Exception: Build failed. Check the Output window for more details.
— End of inner exception stack trace —
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.VisualStudio.Web.Publish.PublishService.VsWebProjectPublish.<>c__DisplayClass43_0.<PublishAsync>b__2()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.<RunPublishTaskAsync>d__127.MoveNext()
—> (Inner Exception #0) System.Exception: Build failed. Check the Output window for more details.<—
===================
«`
Error output in Visual Studio:
«`
Severity Code
Description Project
File Line
Suppression State
Error Web deployment task failed. (Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.)
simple-mvc 0
«`
-
Edited by
Tuesday, November 13, 2018 7:32 PM
i am trying to set up communication with an ethernet device connected to my computer. Connection seems to work ok, when i connect the socket to the device’s IP address and port, but when I try to send a command to the device, it returns the [error 10054 — connection was forcibly interrupted by the remote host]. The code I have so far is like this:
import socket
import time
import logging
logging.basicConfig(filename='conn.txt', filemode='w')
logging.warning('Starting...')
address = ('192.168.1.23', 23)
soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ok = soc.connect_ex(address)
if ok == 0:
logging.warning('Connected to device ' + str(ok))
else:
logging.warning('Connection failed ' + str(ok))
### send at command
command = 'AT+SENSOR_IDS'
cmd_to_send = command + 'rn'
cmd_to_send = cmd_to_send.encode('ascii')
logging.warning('Sending at command')
soc.sendall(cmd_to_send)
logging.warning('at command sent, waiting for echo')
# read echo
echo = soc.recv()
logging.warning('received echo: ' + echo)
print('finished')
When i try to «reconnect» with another soc.connect_ex(address), it tells me that the socket is in use.
——
EDIT
——
So because I don’t know much about the device thanks to the lack of documentation, I decided on simulating the problem just using an Echo server and a client example on a localhost. I have this code:
Server side:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_address = ('localhost', 1001)
s.bind(server_address)
s.listen(1)
# looking for clients
while True:
print('waiting for connection')
connection, client_address = s.accept()
# when client connects
try:
print('Connection from %s port %s' % client_address )
# get all the data and echo it back
while True:
data = connection.recv(32)
print('Received: ' + str(data))
if(len(data)==0):
print('No more data from client')
break
else:
print('sending data to client')
finally:
connection.close()
Client side:
import socket
address = ('127.0.0.1', 1001)
soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ok = soc.connect_ex(address)
try:
if ok == 0:
print('Connected to device ' + str(ok))
else:
print('Connection failed ' + str(ok))
except Exception as e:
soc.close()
print("connection not succesful, error returned :", e)
try:
cmd_to_send = 'AT+SENSOR_IDSrn'.encode('ascii')
bytes_sent = soc.sendall(cmd_to_send, address)
print('Client sent %s bytes' % str(bytes_sent))
# read echo
echo = soc.recv()
print('received echo: ' + echo)
soc.close()
except:
try:
soc.close()
print('process finished, didn't send at command')
except:
print('Process finished socket exception occured')
The problem persists in that way, that the client does not manage to even send the command. It looks like the connection closes just after it has been established. I am new to sockets and I haven’t found any good source for learning about the way how things work with them, only a few basic examples, could somebody help me so that it works at least when simulating on the localhost?
Thank you for your help