-
April 7th, 2007, 08:53 PM
#1
No Sink on Remoting Proxy to Client
The exception is:
System::Runtime::Remoting::RemotingException
Exception details: This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or this application has no suitable client channel to talk to the server.
This occurs when the server attempts to call methods (or delegates to) on a proxy to the client.
First the client "registers" with the server:
Code:
int Controller::ConnectClient(SmartPrioritizer2::IClient^ client)
{
for (int findFreeId = 1; findFreeId < MAX_CLIENTS; findFreeId++)
{
if (!clients->ContainsKey(findFreeId)) {
clients->Add(findFreeId, client);
return findFreeId;
}
}
return -1;
}
The server remember the proxy for the client. Later, the server tries to notify the client of new data:
Code:
void Controller::TransmitProcessUpdated(ProcessController^ processController)
{
array<int>^ ids = gcnew array<int>(clients->Keys->Count);
clients->Keys->CopyTo(ids, 0);
for (int index=0; index < ids->Length; index++)
{
IClient^ client = (IClient^)clients[ids[index]];
client->OnUpdateProcess(processController);
}
}
The client->OnUpdateProcess part is where the exception occurs
This seemed to be a common problem with the switch to .Net 1.1, but as I am using VS 2005 and .Net 2.0 I haven't found anything with quite the same setup.
Nonetheless, I did what the old solutions said.
On the client side I have added:
Code:
channel = gcnew TcpChannel();
ChannelServices::RegisterChannel(channel, true);
I even went as far as:
Code:
//Create custom formatters for a TcpChannel sink chain.
BinaryServerFormatterSinkProvider^ serverFormatSinkProvider = gcnew BinaryServerFormatterSinkProvider();
serverFormatSinkProvider->TypeFilterLevel = System::Runtime::Serialization::Formatters::TypeFilterLevel::Full;
BinaryClientFormatterSinkProvider^ clientFormatSinkProvider = gcnew BinaryClientFormatterSinkProvider();
// Creating the IDictionary to set the port on the channel instance.
System::Collections::IDictionary^ props = gcnew System::Collections::Hashtable();
props["name"] = "Smart Prioritizer 2 Client";
TcpChannel^ channel = gcnew TcpChannel(props, clientFormatSinkProvider, serverFormatSinkProvider);
I also took the sames steps on the server side - still the same problem. Does anyone have an understanding of the problem that I'm not getting, or maybe an out-right solution. Any tips would be greatly appreciated.
-
April 22nd, 2007, 10:50 AM
#2
Re: No Sink on Remoting Proxy to Client
As usual, I was left to solve my own problems. Nonetheless, here is how I got it to work.
When the client registers it's port, a port number must be specified and a format sink must be provided:
Code:
System::Runtime::Remoting::Channels::BinaryServerFormatterSinkProvider^ serverFormatSinkProvider = gcnew System::Runtime::Remoting::Channels::BinaryServerFormatterSinkProvider();
serverFormatSinkProvider->TypeFilterLevel = System::Runtime::Serialization::Formatters::TypeFilterLevel::Full;
// Creating the IDictionary to set the port on the channel instance.
System::Collections::IDictionary^ props = gcnew System::Collections::Hashtable();
props["port"] = 51285;
props["name"] = "Smart Prioritizer 2 Client";
// Pass the properties for the port setting and the server provider in the server chain argument. (Client remains null here.)
TcpChannel^ channel = gcnew TcpChannel(props, nullptr, serverFormatSinkProvider);
ChannelServices::RegisterChannel(channel, true);
Next, when the client actually connects, it must use RegisterWellKnownClientType to specify to remoting that it is going to use the object you are remoting.
Code:
System::Runtime::Remoting::RemotingConfiguration::RegisterWellKnownClientType(IServer::typeid, "tcp://localhost:51285/SmartPrioritizer2Controller");
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|