Comments (7)
The simplest alternation of the code was to remove custom serializers and simplify Request
and Response
records. I also made them exactly the same.
public record Request (
@Deserialize("label") String label
) {
@Override
@Serialize(order = 1)
public String label() {
return label;
}
}
and
public record Response (
@Deserialize("label") String label
) {
@Override
@Serialize(order = 1)
public String label() {
return label;
}
}
those are now the only message types registered along with a single request handler.
RPC client sends Request
. RPC server decodes Response
(not expected) with the data being correct (label=testLabel
) and then can't look up the handler (expected).
2023-04-28T10:28:38.869Z INFO io.activej.rpc.server.RpcServer [RPC Event Loop] Client connected on RpcServerConnection{address=/127.0.0.1, active=1, successes=0, failures=0}
2023-04-28T10:28:38.878Z WARN hostName i.a.rpc.server.RpcServerConnection [RPC Event Loop] Exception while processing request ID 1
io.activej.common.exception.MalformedDataException: Failed to process request Response[label=testLabel]
at io.activej.rpc.server.RpcServerConnection.serve(RpcServerConnection.java:72)
at io.activej.rpc.server.RpcServerConnection.accept(RpcServerConnection.java:85)
at io.activej.rpc.server.RpcServerConnection.accept(RpcServerConnection.java:39)
at io.activej.datastream.AbstractStreamSupplier.send(AbstractStreamSupplier.java:153)
at io.activej.datastream.csp.ChannelDeserializer.process(ChannelDeserializer.java:159)
at io.activej.datastream.csp.ChannelDeserializer.onResumed(ChannelDeserializer.java:83)
at io.activej.datastream.AbstractStreamSupplier.resume(AbstractStreamSupplier.java:142)
at io.activej.datastream.AbstractStreamSupplier.asyncResume(AbstractStreamSupplier.java:135)
at io.activej.datastream.csp.ChannelDeserializer.lambda$onResumed$1(ChannelDeserializer.java:117)
at io.activej.promise.AbstractPromise$25.accept(AbstractPromise.java:1134)
at io.activej.promise.AbstractPromise.complete(AbstractPromise.java:114)
at io.activej.promise.SettablePromise.set(SettablePromise.java:68)
at io.activej.csp.queue.ChannelZeroBuffer.put(ChannelZeroBuffer.java:83)
at io.activej.csp.queue.ChannelQueue$1.doAccept(ChannelQueue.java:66)
at io.activej.csp.AbstractChannelConsumer.accept(AbstractChannelConsumer.java:51)
at io.activej.csp.ChannelSuppliers.lambda$streamToImpl$6(ChannelSuppliers.java:236)
at io.activej.promise.AbstractPromise.complete(AbstractPromise.java:114)
at io.activej.promise.SettablePromise.set(SettablePromise.java:68)
at io.activej.net.socket.tcp.AsyncTcpSocketNio.onReadReady(AsyncTcpSocketNio.java:374)
at io.activej.eventloop.Eventloop.onRead(Eventloop.java:883)
at io.activej.eventloop.Eventloop.processSelectedKeys(Eventloop.java:630)
at io.activej.eventloop.Eventloop.run(Eventloop.java:543)
from activej.
Hi, @ocervinka
You said that the same message types are used on client and server. But is the order of message types the same? If not, then this could cause the issue.
If you are sure that the order of message types is the same on the client and on the server, then could you please create a minimalistic demo that demonstrates the problem? Then I will try to help you with the issue.
from activej.
@eduard-vasinskyi thanks for your help. Indeed the order of message types in List
argument of RpcServer#withMessageTypes
method wasn't guaranteed.
I suggest mentioning in Javadoc of that method that the order is important and must be the same for all application instances in order to communicate to each other.
When RpcServer
and RpcClient
are used directly there is less chance of making this mistake. However, the library kept message types in a Set
for uniqueness because multiple subjects can register their KS IQ calls independently. Then it converted the Set
to a List
which caused the random deserialisation failures.
from activej.
@ocervinka
We will mention in Javadoc that the order of message types matters.
from activej.
@eduard-vasinskyi do you want me to close the issue?
I can create PR with the Javadoc update, although the RpcServer#withMessageTypes
is not in master anymore. It's been replaced by RpcServer#withSerializer
so the Javadoc should be probably added to RpcMessageSerializer#of
methods?
from activej.
@ocervinka
I have updated javadocs in the master-5.5
branch. These changes have been merged into the master
branch.
from activej.
Many thanks @eduard-vasinskyi .
from activej.
Related Issues (20)
- activej-Inject, When the return value of a method has a generic HOT 1
- Bug :java.lang.ArrayIndexOutOfBoundsException: arraycopy: last source index 248 out of bounds for byte[234] HOT 2
- activej-Inject, How to omit `getInstanceInjector(...).injectInto(...)` HOT 2
- Cannot use curly bracket in url for path param HOT 1
- How to use the provided JSON serializer? HOT 1
- How to register with Eureka registry, export OpenTelemetry Tracings and Metrics? HOT 5
- ActiveJ Serializer - Non-static POJOs? HOT 6
- HTTP server Middleware HOT 3
- Constructor not found error for classes without zero-argument constructor, like BigDecimal, Calendar. HOT 1
- Binding automatically between inteface and implementation in DI HOT 2
- Make HTTPResponse's primary response code non-final HOT 4
- Websocket Accept/WriteFrame/WriteMessage not processing more than 2 writes HOT 9
- Suggestion - Nightly Snapshots? HOT 1
- Any sample to declare local varible? HOT 2
- Happen error while uploading file HOT 2
- Release plan for v5.5 and v6 HOT 3
- Add Query Parameters? HOT 6
- RPCClient lock port on local HOT 1
- Version 6 does not support ipv6, version 5.5 supported ipv6 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from activej.