Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the coexistence of a Server and Client sessions in the same process, which consume custom data types. #1514

Merged
merged 3 commits into from
Sep 20, 2021

Conversation

mrsuciu
Copy link
Contributor

@mrsuciu mrsuciu commented Sep 16, 2021

The context of this change is the following:

If the application process is used to create a Server instance and also a Client session to a different server, than if custom data types have been initialized from the current Server instance, the Client session cannot decode the received custom types from the remote Server, due to the collision with the cloned existing ones from the current Server instance.
The type ids from the singleton GlobalFactory which in this case have already been set up by the local Server instance are copied and used instead.

The apparent working solution is to avoid the clone and create a new EncodeableFactory per CreateMessageContext that originates from a Client session.

@mregen
Copy link
Contributor

mregen commented Sep 16, 2021

Could you check if this line is root cause of the mixed up factory and if adding the true would help:

ServerBase.cs, line 1260
            // use the message context from the configuration to ensure the channels are using the same one.
            ServiceMessageContext messageContext = configuration.CreateMessageContext(`true`);
            messageContext.NamespaceUris = new NamespaceTable();
            MessageContext = messageContext;

Currently the server would use a reference to the global factory, after adding the types a client session would get all types from global factory too if the global factory is cloned. With the change a server would use a clone of global factory and types should not be shared.

@mrsuciu
Copy link
Contributor Author

mrsuciu commented Sep 17, 2021

@mregen Yes this is a better solution and it works !!!

…ServerBase::CreateMessageContext(true) to use a clone of EncodeableFactory.GlobalFactory
Copy link
Contributor

@mregen mregen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, this should be less risk for regression..
although a little bigger memory footprint now server always use a clone of the factory.
:shipit:

@mrsuciu mrsuciu merged commit 33cbddb into OPCFoundation:master Sep 20, 2021
@mrsuciu mrsuciu deleted the enableNewEncodeableFactory branch September 20, 2021 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants