Reputation: 141
When I pause my application and then resume after a while, I get this error message:
System.IO.IOException: Unable to read data from the transport connection. Connection reset by peer ---> system.net.sockets.....
public class Connection: Activity
{
protected SqlConnection con;
protected string MyIp;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
var prefs = Application.Context.GetSharedPreferences("Preferences", FileCreationMode.Private);
MyIp = prefs.GetString("IpAdress", null);
con = new SqlConnection("Data Source = " + MyIp + "; Initial Catalog = WiOrder; user id = admin; password = 1234;Connection Timeout=5");
}
}
public class Main : Connection
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
//Rest of my code
con.Open();
SqlCommand cmd = new SqlCommand (//query,con);
//.........
}
}
Upvotes: 6
Views: 43628
Reputation: 3026
I faced the same issue and I was getting this exception (sometimes) when trying to connect to the server.
Unable to read data from the transport connection: Connection reset by peer.
After many searches, I found this answer
Quote from the answer
This error usually means that the target machine is running, but the service that you're trying to connect to is not available. (Either it stopped, crashed, or is busy with another request.)
In English: The connection to the machine (remote host/server/PC that the service runs at) was made but since the service was not available on that machine, the machine didn't know what to do with the request.
So, you should check your network connection
For more information,
Take a look at the similar questions here and here
Upvotes: 4