I have this very strange error...
I am developing on a WCF service, that I've taken over from somebody else. There is a class called User defined like this:
namespace WebApi.DataContracts
{
[DataContract]
public class User
{
[DataMember]
public int Id
{
get;
set;
}
[DataMember]
public string Username
{
set;
get;
}
...
[DataMember]
public DateTime Birth
{
get;
set;
}
[DataMember]
public bool Newsletter
{
get;
set;
}
etc...
I've made a API method, that returns this object as data
namespace WebApi
{
public class SoapApi : IApi
{
public DataContracts.User UserRegister()
{
DataContracts.User u = new DataContracts.User();
return u;
}
}
When I try to call this from a client, I get this error:
[SocketException (0x2746): An existing connection was forcibly closed by the remote host]
System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) +6132200
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +134
[IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.]
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +300
System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) +26
System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead) +265
[WebException: The underlying connection was closed: An unexpected error occurred on a receive.]
System.Net.HttpWebRequest.GetResponse() +6038435
ClassLib.HandlerFactory.AjaxProxy.ProcessRequest(HttpContext context) in ClassLib\HandlerFactory.cs:75
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
It looks to me that this line
System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) +6132200
indicates, that an awful lot of bytes is tried to be sent - why is that?
UPDATE: The binding in my CLIENT web.config is as follows:
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Api" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="ApiBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
SERVER web.config bindings are:
<bindings>
<basicHttpBinding>
<binding name="ApiBinding" />
</basicHttpBinding>
<webHttpBinding>
<binding name="ApiBinding" />
</webHttpBinding>
</bindings>
/ Carsten
By the information you have provided which seems to be only server side, it is impossible to say what the problem is.
So:
Update the information with the client side detail
Now, the error tells me that there is a binding mismatch or security error happening - although security is set to None. So my hunch based on the info provided is a binding mismatch between client and server possibly security is on for one and off for the other.
Related
I am trying to upload a large object (300 MB) from client to service using 'wsDualHttpBinding'.
Using 'basicHttpBinding', I able to upload large object (1.5 GB file).
I need to use 'wsDualHttpBinding'. But, using 'wsDualHttpBinding', I able to upload 28 MB only.
If I upload 100 MB object, it says ''Failed to allocate a managed memory buffer ...'
Could you tell me, how to upload large object (300 MB) using 'wsDualHttpBinding'.
Thanks In Advance,
Murugan
Here is the configuration I am using:
<wsDualHttpBinding>
<binding name="Test"
closeTimeout="04:10:00"
openTimeout="04:10:00"
receiveTimeout="04:10:00"
sendTimeout="04:10:00"
bypassProxyOnLocal="false"
transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
messageEncoding="Mtom"
textEncoding="utf-16"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<reliableSession
ordered="true"
inactivityTimeout="04:10:00" />
<security mode="Message">
<message clientCredentialType="Windows"
negotiateServiceCredential="true" />
</security>
</binding>
</wsDualHttpBinding>
And contracts
public interface IFileUploaderService
{
[OperationContract]
void Upload(MyFileInfo remoteFileInfo);
}
public interface IFileUploaderServiceCallBack
{
[OperationContract(IsOneWay = true)]
void OnNotificationSend(string message);
}
[MessageContract]
public class MyFileInfo : IDisposable
{
[MessageBodyMember(Order = 1)]
public System.IO.Stream FileByteStream;
public void Dispose()
{
if (FileByteStream != null)
{
FileByteStream.Close();
FileByteStream = null;
}
}
}
I have a WPF program calling a WCF service. it all works fine on my PC but on a customer PC I get the following error.
[Footer][Header]2011-12-20 10:54:29,809 [5] WARN
Kern.Common.Logging.Logger - Error logging in - An exception occurred
during the operation, making the result invalid. Check InnerException
for exception details. 2011-12-20 10:54:29,928 [5] WARN
Kern.Common.Logging.Logger - Inner Exception -
System.TypeLoadException: Could not load type 'ChannelBase1' from
assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'. at
KernMobile.Data.Server.KernMobileWcfService.KernServiceClient.CreateChannel()
at System.ServiceModel.ClientBase1.CreateChannelInternal() at
System.ServiceModel.ClientBase1.get_Channel() at
KernMobile.Data.Server.KernMobileWcfService.KernServiceClient.KernMobile.Data.Server.KernMobileWcfService.IKernService.BeginLogin(String
username, String password, AsyncCallback callback, Object asyncState)
at
KernMobile.Data.Server.KernMobileWcfService.KernServiceClient.OnBeginLogin(Object[]
inValues, AsyncCallback callback, Object asyncState) at
System.ServiceModel.ClientBase1.InvokeAsync(BeginOperationDelegate
beginOperationDelegate, Object[] inValues, EndOperationDelegate
endOperationDelegate, SendOrPostCallback operationCompletedCallback,
Object userState)
I turned on WCF tracing but there are no errors reported in the log file.
Here is the service config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IKernService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/Kern.Server.Service/KernService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IKernService"
contract="KernMobileWcfService.IKernService" name="BasicHttpBinding_IKernService" />
</client>
</system.serviceModel>
Any ideas?
Finally fixed this.
It was caused by using a portable library project as a wrapper for the WCF service reference.
This worked fine on most PCs but failed on a customers locked down hardware. I'm assuming some supporting DLL's were missing.
I changed changed over to a normal class library project and all worked.
Must be doing something awfully wrong here. Here is what I'm trying to do.
I have a Message handler that should get a message from the queue. Make a WCF call, do stuff and when done, send a new message out on the bus.
It is hosted in the NServiceBus.Host.Exe.
But, whenever I create the Service Client, eveything comes to a grinding halt. If I comment out the service call everything works great... Except, I need that call.
Is there a trick I must do to make WCF calls from my Message Handler when hosting it in the NServiceBus.Host.Exe? I have not made any special config in the EndPointConfig class.
public class EndpointConfig :
IConfigureThisEndpoint, AsA_Server { }
public class RequestAccountUpdateMessageHandler : IHandleMessages<RequestAccountUpdateMessage>
{
public void Handle(RequestAccountUpdateMessage message)
{
// The Line below hangs everything
AccountService.AccountServiceClient client =
new AccountService.AccountServiceClient();
resp = client.DoStuff(message.parameter);
Bus.Send<UpdateAccountMessage>(m =>
{
m.info = DoMagicStuffHere(resp);
});
}
...
}
This is what the system.serviceModel looks like in the App.Config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAccountService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://yadayafa/accountservice.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAccountService" contract="AccountService.IAccountService" name="BasicHttpBinding_IAccountService"/>
</client>
</system.serviceModel>
I've successfully got a few workflows going with Server AppFabric.
What i have noticed however is that when i try to use namePipeBinding to communicate with the workflow then the call works successfully for the client (the call is marked As IsOneWay=true in the interface definition for the service) but in the AppFabric dashboard i can see the message being processed successfully and then we get the call appearing as a 'Service Exception' with the following exception
System.ServiceModel.CommunicationException: There was an error reading from the pipe: The pipe has been ended. (109, 0x6d). ---> System.IO.IOException: The write operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: There was an error reading from the pipe: The pipe has been ended. (109, 0x6d). ---> System.IO.PipeException: There was an error reading from the pipe: The pipe has been ended. (109, 0x6d).
at System.ServiceModel.Channels.PipeConnection.OnAsyncReadComplete(Boolean haveResult, Int32 error, Int32 numBytes)
--- End of inner exception stack trace ---
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ConnectionStream.ReadAsyncResult.End(IAsyncResult result)
at System.Net.FixedSizeReader.ReadCallback(IAsyncResult transportResult)
--- End of inner exception stack trace ---
at System.Net.Security.NegotiateStream.EndRead(IAsyncResult asyncResult)
at System.ServiceModel.Channels.StreamConnection.EndRead()
--- End of inner exception stack trace ---
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.FramingDuplexSessionChannel.TryReceiveAsyncResult.End(IAsyncResult result, Message& message)
at System.ServiceModel.Dispatcher.DuplexChannelBinder.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
at System.ServiceModel.Dispatcher.ErrorHandlingReceiver.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
The workflow consists of two receive activities but it doesn't have any receiveandsendreply activitiies.
Everything works fine when i use http bindings.
Why is this error being reported in the dashboard?
Configuration details for the client app are shown below
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISLG" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<netNamedPipeBinding>
<binding name="NetNamedPipeBinding_ISLG" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport protectionLevel="EncryptAndSign"/>
</security>
</binding>
</netNamedPipeBinding>
</bindings>
<client>
<endpoint address="net.pipe://vm-vsnet2010/TestWorkflowDeclarativeServiceLibrary/Service3.xamlx"
binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_ISLG"
contract="SLGService.ISLG" name="NetNamedPipeBinding_ISLG">
<identity>
<servicePrincipalName value="host/VM-VSNET2010" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Can you submit the server binding configuration? They may differ and that's why the server can't receive data from the pipe.
Regards
We have a WCF Service deployed on Windows Server 2003 that handles file transfers. When file is in Unix format, I am converting it to Dos format in the initialization stage using System.Diagnostics.Process (.WaitForExit()). Client calls the service:
obj_DataSenderService = New DataSendClient()
obj_DataSenderService.InnerChannel.OperationTimeout = New TimeSpan(0, System.Configuration.ConfigurationManager.AppSettings("DatasenderServiceOperationTimeout"), 0)
str_DataSenderGUID = obj_DataSenderService.Initialize(xe_InitDetails.GetXMLNode)
This works fine, however for large files the conversion takes more than 10 minutes and I am getting exception:
A first chance exception of type
'System.ServiceModel.CommunicationException'
occurred in mscorlib.dll
Additional information: The socket
connection was aborted. This could be
caused by an error processing your
message or a receive timeout being
exceeded by the remote host, or an
underlying network resource issue.
Local socket timeout was
'00:59:59.8749992'.
I tried configuring both client:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IDataSend" closeTimeout="01:00:00"
openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:4000/DataSenderEndPoint"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IDataSend"
contract="IDataSend" name="NetTcpBinding_IDataSend">
<identity>
<servicePrincipalName value="host/localhost" />
<!--<servicePrincipalName value="host/axopwrapp01.Corp.Acxiom.net" />-->
</identity>
</endpoint>
</client>
</system.serviceModel>
And service:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IDataSend" closeTimeout="01:00:00"
openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
maxReceivedMessageSize="65536">
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
but without luck. In the Service trace viewer I can see:
Close process timed out waiting for service dispatch to complete.
with stack trace:
System.ServiceModel.ServiceChannelManager.CloseInput(TimeSpan
timeout)
System.ServiceModel.Dispatcher.InstanceContextManager.CloseInput(TimeSpan
timeout)
System.ServiceModel.ServiceHostBase.OnClose(TimeSpan
timeout)
System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan
timeout)
System.ServiceModel.Channels.CommunicationObject.Close()
DataSenderService.DataSender.OnStop()
System.ServiceProcess.ServiceBase.DeferredStop()
System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr
md, Object[] args, Object server,
Int32 methodPtr, Boolean
fExecuteInContext, Object[]&
outArgs)
System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle
md, Object[] args, Object server,
Int32 methodPtr, Boolean
fExecuteInContext, Object[]&
outArgs)
System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage
msg, IMessageSink replySink)
System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.DoAsyncCall()
System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object
o)
System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object
state)
System.Threading.ExecutionContext.runTryCode(Object
userData)
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object
userData)
System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback
callback, Object state)
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback
callback, Object state)
System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback
tpWaitCallBack)
System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object
state)
Many thanks
Bartek
Does your WCF service actually return the file contents? If so, perhaps you should use WCF's capability for streaming, and change the line endings from Unix to DOS style as you stream it, rather than processing the file and then returning it as you are currently doing. Read in each line, and then stream it out with the correct line ending.