digitaldrew
Well-known member
- Joined
- Nov 10, 2012
- Messages
- 167
- Programming Experience
- Beginner
I'm having a strange issue with SSLstream which I haven't experienced before...
I connect to this server by sending a greeting request first, getting the greeting response, then sending my login request with credentials, and finally reading my login request to make sure I have logged in successfully. Two thirds of the time everything is fine and I get logged in no problem. But, a small portion of the time I get a 'System.OutOfMemoryException' error.
I started digging a little deeper to see if I could figure out what the issue might be, but can't really understand why most of the time I would have no problems, but then a small portion of the time get this exception. To make things more confusing, I am located a fair distance away from the server which I am connecting to. However, when I use a VPS (which is very very close to this server) it will get a 'System.OutOfMemoryException' error every single time I try to login.
Upon doing more testing on my local PC, I found that when my program is trying to read the SSLstream response for the login request that was sent, it's actually seeing the last part of the greeting response that I receive. If I look at the response captured after sending my login request, if it's the response from my login request then all will work fine. However, if it's the last part of the greeting response the server sends then I get the exception..
I will try to explain it with some code....
Here is how I am connecting, sending and receiving with the server:
Normally, my entire greeting response would look like this:
When doing a messagebox for "greeting" in the code above, if I get the entire greeting then it logins in and there are no problems. But sometimes that messagebox only displays:
And then when looking at the messagebox for "requestResponse" I will see this:
When this is the case, I will get the exception and it will fail. I should be seeing the entire greeting response when looking at the "greeting" messagebox, and the entire login response when looking at the "requestResponse" messagebox..
Any idea what could be wrong here or how I can fix it? Does this seem like an actual memory issue or something to do with not getting the entire SSLstream response? Thanks in advance!
I connect to this server by sending a greeting request first, getting the greeting response, then sending my login request with credentials, and finally reading my login request to make sure I have logged in successfully. Two thirds of the time everything is fine and I get logged in no problem. But, a small portion of the time I get a 'System.OutOfMemoryException' error.
I started digging a little deeper to see if I could figure out what the issue might be, but can't really understand why most of the time I would have no problems, but then a small portion of the time get this exception. To make things more confusing, I am located a fair distance away from the server which I am connecting to. However, when I use a VPS (which is very very close to this server) it will get a 'System.OutOfMemoryException' error every single time I try to login.
Upon doing more testing on my local PC, I found that when my program is trying to read the SSLstream response for the login request that was sent, it's actually seeing the last part of the greeting response that I receive. If I look at the response captured after sending my login request, if it's the response from my login request then all will work fine. However, if it's the last part of the greeting response the server sends then I get the exception..
I will try to explain it with some code....
Here is how I am connecting, sending and receiving with the server:
VB.NET:
Public Function Login() As Boolean
Dim greeting As String = String.Empty
Dim requestResponse As String = String.Empty
Try
'First, initiate SSLstream connection
client = New TcpClient(txtEppServer.Text.Trim, 700)
sslStream = New Security.SslStream(client.GetStream(), True)
sslStream.AuthenticateAsClient(txtEppServer.Text.Trim)
Dim loginElement As XElement
loginElement = MY-LOGIN-XML-CODE-HERE
'Second, get the greeting response and look at it
greeting = GetResponse(sslStream, System.Text.Encoding.UTF8)
MsgBox(greeting)
'Third, send the login request
SendRequest(loginElement.ToString, sslStream, System.Text.Encoding.UTF8)
'Finally, get the login response and look at it
requestResponse = GetResponse(sslStream, System.Text.Encoding.UTF8)
MsgBox(requestResponse)
Catch ex As Exception
MsgBox(ex.Message)
Return False
End Try
End Function
Normally, my entire greeting response would look like this:
VB.NET:
<xml>
<access>none</access>
<greeting>
</greeting>
</xml>
When doing a messagebox for "greeting" in the code above, if I get the entire greeting then it logins in and there are no problems. But sometimes that messagebox only displays:
VB.NET:
<xml>
<access>none</access>
<greeting>
And then when looking at the messagebox for "requestResponse" I will see this:
VB.NET:
</greeting>
</xml>
When this is the case, I will get the exception and it will fail. I should be seeing the entire greeting response when looking at the "greeting" messagebox, and the entire login response when looking at the "requestResponse" messagebox..
Any idea what could be wrong here or how I can fix it? Does this seem like an actual memory issue or something to do with not getting the entire SSLstream response? Thanks in advance!