WCF Issue


G

Guest

I am not sure if this is the right form because I didn't see any WCF forms.
Anyway, I made a very simple WCF object and hosted it in IIS. Now I have a
client that builds 20 threads, and have each thread call the WCF object and
half the threads work and the other half get:

System.ServiceModel.CommunicationObjectFaultedException was caught
Message="The communication object,
System.ServiceModel.Channels.ServiceChannel, cannot be used for communication
because it is in the Faulted state."
Source="mscorlib"
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan
timeout)
Exception rethrown at [0]:
at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,
Int32 type)
at System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)
at
System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)
at System.ServiceModel.ClientBase`1.Close()
at System.ServiceModel.ClientBase`1.System.IDisposable.Dispose()
at WCFTestApp.Program.ThreadProc() in
C:\projects\WCFIISTesting\WCFTestApp\Program.cs:line 44
InnerException:

Here is my code my service code:

using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WCFTestModule
{
[ServiceContract(Namespace =
"http://www.mynamespace.biz/2007/08/WSTesting", SessionMode =
SessionMode.Required)]
interface IWSSessionTesting
{
[OperationContract]
void SetString(string s);
[OperationContract]
string GetString();
[OperationContract]
void Pause(int lenght);
}

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
public class WSSessionTesting : IWSSessionTesting
{
#region IWSSessionTesting Members

public void SetString(string s)
{
_s = s;
}

public string GetString()
{
if (_s == null)
return "No Value in Session";

return _s;
}

public void Pause(int length)
{
System.Diagnostics.Trace.WriteLine("About To Goto sleep.");
System.Threading.Thread.Sleep(length);
}

private string _s = null;

#endregion
}
}

here is my web.config code:

<configuration>
<system.web>
<authentication mode="Windows" />
<compilation debug="true"/>
</system.web>

<system.serviceModel>
<services>
<service name="WCFTestModule.WSSessionTesting"
behaviorConfiguration="WCFTestModule.ServiceBehavior">
<endpoint binding="wsHttpBinding"
contract="WCFTestModule.IWSSessionTesting"/>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCFTestModule.ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>

here is my client code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace WCFTestApp
{
class Program
{
static void Main(string[] args)
{
int total = 20;
Thread[] t = new Thread[total];

for (int i = 0; i < total; i++)
{
t = new Thread(new ThreadStart(ThreadProc));
t.Name = "Thread " + (i + 1).ToString();
t.Start();
}
Console.ReadLine();

}

static void ThreadProc()
{
try
{
using (WCFTestApp.WCFIISTestingWSDL.WSSessionTestingClient
proxy = new WCFTestApp.WCFIISTestingWSDL.WSSessionTestingClient())
{
//proxy.SetString("This is a test");

Console.WriteLine(String.Format("Returned Value on
Thread Name {0}: {1}", Thread.CurrentThread.Name, proxy.GetString()));
//proxy.Pause(60000);
//Console.ReadLine();
}
}
catch (Exception e)
{
if(e.InnerException != null)
Console.WriteLine("Exception and InnerException: {0} :
{1}", e.Message, e.InnerException.Message);
else
Console.WriteLine("Exception: {0}", e.Message);
}
}
}
}

Most of the time half the threads get an error and the other half doesn't.
Someones the errors are the first 10, sometimes the last 10 and sometimes
every other. Anyway, if anyone knows what my problem is please let me know.

I'm also compling this with Visual Studios 2008 on Windows XP SP2.

Thanks,
MAA
 
Ad

Advertisements

G

Guest

WCF Web Site, including Forums:

http://wcf.netfx3.com/

-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com



BravesCharm said:
I am not sure if this is the right form because I didn't see any WCF forms.
Anyway, I made a very simple WCF object and hosted it in IIS. Now I have a
client that builds 20 threads, and have each thread call the WCF object and
half the threads work and the other half get:

System.ServiceModel.CommunicationObjectFaultedException was caught
Message="The communication object,
System.ServiceModel.Channels.ServiceChannel, cannot be used for communication
because it is in the Faulted state."
Source="mscorlib"
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan
timeout)
Exception rethrown at [0]:
at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,
Int32 type)
at System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)
at
System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)
at System.ServiceModel.ClientBase`1.Close()
at System.ServiceModel.ClientBase`1.System.IDisposable.Dispose()
at WCFTestApp.Program.ThreadProc() in
C:\projects\WCFIISTesting\WCFTestApp\Program.cs:line 44
InnerException:

Here is my code my service code:

using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WCFTestModule
{
[ServiceContract(Namespace =
"http://www.mynamespace.biz/2007/08/WSTesting", SessionMode =
SessionMode.Required)]
interface IWSSessionTesting
{
[OperationContract]
void SetString(string s);
[OperationContract]
string GetString();
[OperationContract]
void Pause(int lenght);
}

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
public class WSSessionTesting : IWSSessionTesting
{
#region IWSSessionTesting Members

public void SetString(string s)
{
_s = s;
}

public string GetString()
{
if (_s == null)
return "No Value in Session";

return _s;
}

public void Pause(int length)
{
System.Diagnostics.Trace.WriteLine("About To Goto sleep.");
System.Threading.Thread.Sleep(length);
}

private string _s = null;

#endregion
}
}

here is my web.config code:

<configuration>
<system.web>
<authentication mode="Windows" />
<compilation debug="true"/>
</system.web>

<system.serviceModel>
<services>
<service name="WCFTestModule.WSSessionTesting"
behaviorConfiguration="WCFTestModule.ServiceBehavior">
<endpoint binding="wsHttpBinding"
contract="WCFTestModule.IWSSessionTesting"/>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCFTestModule.ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>

here is my client code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace WCFTestApp
{
class Program
{
static void Main(string[] args)
{
int total = 20;
Thread[] t = new Thread[total];

for (int i = 0; i < total; i++)
{
t = new Thread(new ThreadStart(ThreadProc));
t.Name = "Thread " + (i + 1).ToString();
t.Start();
}
Console.ReadLine();

}

static void ThreadProc()
{
try
{
using (WCFTestApp.WCFIISTestingWSDL.WSSessionTestingClient
proxy = new WCFTestApp.WCFIISTestingWSDL.WSSessionTestingClient())
{
//proxy.SetString("This is a test");

Console.WriteLine(String.Format("Returned Value on
Thread Name {0}: {1}", Thread.CurrentThread.Name, proxy.GetString()));
//proxy.Pause(60000);
//Console.ReadLine();
}
}
catch (Exception e)
{
if(e.InnerException != null)
Console.WriteLine("Exception and InnerException: {0} :
{1}", e.Message, e.InnerException.Message);
else
Console.WriteLine("Exception: {0}", e.Message);
}
}
}
}

Most of the time half the threads get an error and the other half doesn't.
Someones the errors are the first 10, sometimes the last 10 and sometimes
every other. Anyway, if anyone knows what my problem is please let me know.

I'm also compling this with Visual Studios 2008 on Windows XP SP2.

Thanks,
MAA
 
Ad

Advertisements

G

Guest

Peter Bromberg said:
WCF Web Site, including Forums:

http://wcf.netfx3.com/

-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com



BravesCharm said:
I am not sure if this is the right form because I didn't see any WCF forms.
Anyway, I made a very simple WCF object and hosted it in IIS. Now I have a
client that builds 20 threads, and have each thread call the WCF object and
half the threads work and the other half get:

System.ServiceModel.CommunicationObjectFaultedException was caught
Message="The communication object,
System.ServiceModel.Channels.ServiceChannel, cannot be used for communication
because it is in the Faulted state."
Source="mscorlib"
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan
timeout)
Exception rethrown at [0]:
at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,
Int32 type)
at System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)
at
System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)
at System.ServiceModel.ClientBase`1.Close()
at System.ServiceModel.ClientBase`1.System.IDisposable.Dispose()
at WCFTestApp.Program.ThreadProc() in
C:\projects\WCFIISTesting\WCFTestApp\Program.cs:line 44
InnerException:

Here is my code my service code:

using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WCFTestModule
{
[ServiceContract(Namespace =
"http://www.mynamespace.biz/2007/08/WSTesting", SessionMode =
SessionMode.Required)]
interface IWSSessionTesting
{
[OperationContract]
void SetString(string s);
[OperationContract]
string GetString();
[OperationContract]
void Pause(int lenght);
}

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
public class WSSessionTesting : IWSSessionTesting
{
#region IWSSessionTesting Members

public void SetString(string s)
{
_s = s;
}

public string GetString()
{
if (_s == null)
return "No Value in Session";

return _s;
}

public void Pause(int length)
{
System.Diagnostics.Trace.WriteLine("About To Goto sleep.");
System.Threading.Thread.Sleep(length);
}

private string _s = null;

#endregion
}
}

here is my web.config code:

<configuration>
<system.web>
<authentication mode="Windows" />
<compilation debug="true"/>
</system.web>

<system.serviceModel>
<services>
<service name="WCFTestModule.WSSessionTesting"
behaviorConfiguration="WCFTestModule.ServiceBehavior">
<endpoint binding="wsHttpBinding"
contract="WCFTestModule.IWSSessionTesting"/>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCFTestModule.ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>

here is my client code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace WCFTestApp
{
class Program
{
static void Main(string[] args)
{
int total = 20;
Thread[] t = new Thread[total];

for (int i = 0; i < total; i++)
{
t = new Thread(new ThreadStart(ThreadProc));
t.Name = "Thread " + (i + 1).ToString();
t.Start();
}
Console.ReadLine();

}

static void ThreadProc()
{
try
{
using (WCFTestApp.WCFIISTestingWSDL.WSSessionTestingClient
proxy = new WCFTestApp.WCFIISTestingWSDL.WSSessionTestingClient())
{
//proxy.SetString("This is a test");

Console.WriteLine(String.Format("Returned Value on
Thread Name {0}: {1}", Thread.CurrentThread.Name, proxy.GetString()));
//proxy.Pause(60000);
//Console.ReadLine();
}
}
catch (Exception e)
{
if(e.InnerException != null)
Console.WriteLine("Exception and InnerException: {0} :
{1}", e.Message, e.InnerException.Message);
else
Console.WriteLine("Exception: {0}", e.Message);
}
}
}
}

Most of the time half the threads get an error and the other half doesn't.
Someones the errors are the first 10, sometimes the last 10 and sometimes
every other. Anyway, if anyone knows what my problem is please let me know.

I'm also compling this with Visual Studios 2008 on Windows XP SP2.

Thanks,
MAA


Thanks, I posted my quest there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top