RPC not working: What I am doing wrong? Is there an example of its implementation?
See original GitHub issueGreetings,
Will you help me?
I apologize to bother but I am having troubles implementing RPC correctly.
Perhaps someone can point out what I am doing wrong in the code since I couldn’t find in the documentation a full example on how to implemented.
// Publish RPC from this client to server
var extension = {
id: UUID.random(),
}
var body = {...};
rabbit.publish('rpc.extension.request', {
routingKey: 'extend.rpc',
correlationId: extension.id,
replyTo: "rpc.extension.response",
contentType: "application/json",
body: body,
expiresAfter: 60000 // TTL in ms, in this example 60 seconds - can be removed after consumer working, just here to prevent junk accumulating on servers.
}).then(
() => { // a list of the messages of that succeeded
log.info(`Success publishing extension for rpc ${extension.id}`);
},
(failed) => { // a list of failed messages and the errors `{ err, message }`
log.info(`Error publishing extension for rpc ${extension.id} -> ${failed.err}: ${failed.message}`);
});
-----------------------
// Consuming RPC result sent by server to this client.
module.exports.setup = function () {
...
const handleRPC = rabbit.handle({queue: 'rpc.extension.response'}, handleExtendRPCResponse);
handleRPC.catch(onHandleError);
};
function handleExtendRPCResponse(msg) {
logger.info(`RPC Received message : ${msg}`)
try {
messageHandler.processMessage(msg, function (err) {
if (err) {
logger.error(`ERROR in RPC Process message: "${err.error}"`);
msg.reject();
} else {
logger.info("Process RPC message passed");
msg.ack();
}
})
} catch(e){
logger.error(`ERROR while Processing RPC message: "${e.message}"`);
msg.reject();
}
}
function onHandleError (err, msg) {
// not able to hit this with a test...not sure how to.
logger.error('Error:', JSON.stringify(err), 'Message:', JSON.stringify(msg));
// Temporary, but if we can't handle it we don't want it requeued.
msg.reject();
}
Thanks for your time and the creation of this package.
Issue Analytics
- State:
- Created 5 years ago
- Comments:14
Top Results From Across the Web
RPC error troubleshooting guidance - Windows Client
Learn how to troubleshoot Remote Procedure Call (RPC) errors that occur during computer-to-computer communication.
Read more >Tips To Handle RPC Request Errors - Chainstack Blog
We are sharing different solutions to handle RPC request errors in your application: promise methods, retries, and backup providers.
Read more >REST vs. RPC: what problems are you trying to solve with ...
Calling a remote procedure is usually syntactically the same as calling a normal programming language procedure, and learning the procedures of ...
Read more >Writing an RPC From Scratch - Caffeinspiration
This is where remote procedure calls come into play. We can wrap the complexity of inter-computer communication in the center, and we can ......
Read more >Lecture 9: February 20 9.1 Failure Semantics - LASS
doesn't implement any error correction or handles packet losses in the network. ... For example, client made a RPC request, but before the....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I figured out the issue. In the topology, when creating the exchange, I needed to add ‘subscribe:true’ property since the queue was already created but used as publish instead of request.
Thanks anyways for the feedback. I appreciate it.
That makes sense why this problem seemed so familiar. I helped @fifthfloorsoftware with this back then