cancel
Showing results for 
Search instead for 
Did you mean: 

Received an unexpected EOF or 0 bytes from the transport stream. (CoffeeShopWebApp)

I have downloaded the AuthorizeNet solution from github, which contains a project CoffeeShopWebApp.  After changing the API Login and Transaction Key values in web.config, I built the solution successfully on my pc (Visual Studio 2013).  However, when I run the CoffeeShopWebApp (debug is enabled), after clicking on the button to purchase the coffee (using test credit card info), I get this error:

Received an unexpected EOF or 0 bytes from the transport stream.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream.

Source Error:

Line 71:             // post data is sent as a stream
Line 72:             StreamWriter myWriter = null;
Line 73:             myWriter = new StreamWriter(webRequest.GetRequestStream());Line 74:             myWriter.Write(postData);
Line 75:             myWriter.Close();


Source File: c:\Users\Bob\Documents\farodegracia\AuthorizeNet-C_sharp\sdk-dotnet-master\sdk-dotnet-master\Authorize.NET\AIM\Gateway.cs    Line: 73

Stack Trace:

[IOException: Received an unexpected EOF or 0 bytes from the transport stream.]
   System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count) +5391218
   System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) +102
   System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) +181
   System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) +49
   System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) +137
   System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest) +143
   System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult) +99
   System.Net.TlsStream.CallProcessAuthentication(Object state) +47
   System.Threading.ExecutionContext.runTryCode(Object userData) +80
   System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) +0
   System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) +102
   System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) +68
   System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result) +746
   System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size) +58
   System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size) +26
   System.Net.ConnectStream.WriteHeaders(Boolean async) +124

[WebException: The underlying connection was closed: An unexpected error occurred on a send.]
   System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) +1880801
   System.Net.HttpWebRequest.GetRequestStream() +13
   AuthorizeNet.Gateway.SendRequest(String serviceUrl, IGatewayRequest request) in c:\Users\Bob\Documents\farodegracia\AuthorizeNet-C_sharp\sdk-dotnet-master\sdk-dotnet-master\Authorize.NET\AIM\Gateway.cs:73
   AuthorizeNet.Gateway.Send(IGatewayRequest request, String description) in c:\Users\Bob\Documents\farodegracia\AuthorizeNet-C_sharp\sdk-dotnet-master\sdk-dotnet-master\Authorize.NET\AIM\Gateway.cs:119
   AuthorizeNet.Gateway.Send(IGatewayRequest request) in c:\Users\Bob\Documents\farodegracia\AuthorizeNet-C_sharp\sdk-dotnet-master\sdk-dotnet-master\Authorize.NET\AIM\Gateway.cs:42
   CoffeeShopWebApp.Order.btnOrder_Click(Object sender, EventArgs e) in c:\Users\Bob\Documents\farodegracia\AuthorizeNet-C_sharp\sdk-dotnet-master\sdk-dotnet-master\CoffeeShopWebApp\Order.aspx.cs:40
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

 


Version Information: Microsoft .NET Framework Version:2.0.50727.8669; ASP.NET Version:2.0.50727.5491

farodegracia9
Member
1 ACCEPTED SOLUTION

Accepted Solutions

The version is fine now.

using System.Net; 
using System.Security.Authentication;

In the function where you make your web request, try:

 const SslProtocols _Tls12 = (SslProtocols)0x00000C00;
 const SecurityProtocolType Tls12 = (SecurityProtocolType)_Tls12;
 ServicePointManager.SecurityProtocol = Tls12;
Powered by NexWebSites.com -
Certified Authorize.net developers

View solution in original post

4 REPLIES 4
You will probably want to upgrade your .Net Framework version to at least 4.5, preferably 4.6, in order to more easily make TLS 1.2 connections.
Powered by NexWebSites.com -
Certified Authorize.net developers
NexusSoftware
Trusted Contributor

Still getting the same error after upgrading and rebuilding the project.

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2053.0


When I go to the properties page of the project in Visual Studio 2013, there is a drop down to select the target framework.  I selected .NET Framework 4.5, so I don't know why the version information above (which appears at bottom of error page) shows version 4.0.30319

farodegracia9
Member

The version is fine now.

using System.Net; 
using System.Security.Authentication;

In the function where you make your web request, try:

 const SslProtocols _Tls12 = (SslProtocols)0x00000C00;
 const SecurityProtocolType Tls12 = (SecurityProtocolType)_Tls12;
 ServicePointManager.SecurityProtocol = Tls12;
Powered by NexWebSites.com -
Certified Authorize.net developers

Yes, that worked and thanks.  I am wondering why sample code (CoffeeShopWebApp project) was included in the AuthorizeNet download from github that won't run without some modification.

farodegracia9
Member