Is it possible to run 2 instances of a ro sdk server on different ports

2RosdkServers2Ports.zip (1.2 MB)
I’ve added a dummy project trying to run two instances of the SmallService on different ports. When I try to run this I get an ArgumentException stating that an item with the same key has already been added.
Is it possible to configure SmallService in some way that this can work. The idea is that on port 6789 I talk to 1 instance of the SmallService And through port 6790 to another instance of the SmallService

Do you have a stack trace for that exception? In theory, two serves should not interfere wit they open different ports; this sounds like they maybe access a shared resource (like, write to the same log or config file, or something like that?)

at RemObjects.SDK.Server.ConfigurationWrapper.TryLoad(Type[] types, Object[] parameters)
at RemObjects.SDK.Server.ConfigurationWrapper.Load(String applicationName, String rodlNamespace)
at RemObjects.SDK.Server.ConfigurationLoader.LoadConfiguration(Type type)
at RemObjects.SDK.Server.ConfigurationLoader.LoadConfiguration()
at RemObjects.SDK.Server.ConfigurationLoader.Load()
at RemObjects.SDK.Server.ApplicationServer.LoadApplicationServerConfiguration()
at RemObjects.SDK.Server.ApplicationServer.RunAsConsoleApplication()
at RemObjects.SDK.Server.ApplicationServer.RunConsoleApplication()
at RemObjects.SDK.Server.ApplicationServer.RunOnNetFX()
at RemObjects.SDK.Server.ApplicationServer.Run(String[] arguments)
at _2RosdkServers2Ports.Program.<>c__DisplayClass1_0.b__1() in D:\Training\Remobjects sdk\2RosdkServers2Ports\2RosdkServers2Ports\Program.cs:line 27
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)

Curious. that sounds like a bug.

To be clear — is this with tow separate instances of your server executable, or with two server objects created inside the same process? (both should work, of course).

The zip file attached to this case contains a dummy projects which shows the issue.
Two different ApplicationServers are ran on different treads

Is it possible to run 2 instances of a ro sdk server on different ports?

Yes, it is. But not in the way you try to do. Actually your code won’t even start properly.

Instances of a RO SDK services are created and recycled when needed(*). You should never assume that there is some particular “instance” of the service.

*) Concrete lifecycle of service worker instances depends on the Class Factory used ( https://docs.remotingsdk.com/Servers/Concepts/ClassFactories ). The default one destroys service instances once they’ve done their work.

Anyway, if all you need is to have a server that listens to 2 different ports then you can use the approach described here: https://docs.remotingsdk.com/Servers/Concepts/ApplicationServerClassNet/ section Custom Network Server

Here’s a sample of RO SDK server that exposes 2 server channels on different ports: SecondPort.zip (59.1 KB)

Thanks for the explanation. The sample you’ve added (secondPort.zip) helped me a lot. I did not really need separate instances of the server, but from the different ports a different instance of some object needed to be accessed. I’ve found a solution for that using a Session value that is set during login in the loginservice.

1 Like

That does sound to be the more appropriate solution, yes.