Closed b-antwan closed 8 months ago
Hey @b-antwan!
I haven't actually tried testing your example yet, but just glancing through it, in your Slice file, you should change
mode = Slice2
to mode = Slice1
In addition to some other things, it ensures that the Slice definitions are encoded in a way that Ice can consume.
Slice2
only works with IceRPC. You can check this page for more information if you're curious:
https://docs.icerpc.dev/icerpc-for-ice-users/slice/new-slice#compilation-mode-and-encoding-version
I believe I found the real issue:
greeter = VisitorCenter.GreeterPrx.checkedCast(base)
You should change this to an unchecked cast:
greeter = VisitorCenter.GreeterPrx.uncheckedCast(base)
I'll write another comment with an explanation about why you need to do this, but if you don't want to wait on me, it's also outlined here: https://docs.icerpc.dev/icerpc-for-ice-users/slice/ice-object#checked-cast
TL;DR
The Slice2 encoding is only used by IceRPC, Ice can't handle it. To fix this, change your .slice
file to use mode = Slice1
.
This tells IceRPC to use the 1.1 encoding, which Ice can understand.
Use unchecked casts instead of checked casts.
Thanks a lot for your help @InsertCreativityHere ! I was looking into changing the encoding in the python client as well thinking it defaulted to 1.1 instead of 1.0. But your second comment did solve the issue!
Yeah of course!
Calling checkedCast
actually makes an RPC - it asks the other side "hey, is this actually the type I'm requesting?",
specifically it calls the ice_isA
operation.
In Ice, this operation is built in for all proxy types, but with IceRPC, you have to explicitly opt into it (by implementing Ice.Object
).
But IMO, checked casts are rarely (if ever) needed. In this case, you're already fully aware what type the proxy is, so unchecked cast is completely fine.
Hello, I'm trying to get interoperability working with an IceRPC server and a python Ice client. I tried to get a simple greeter to work at first, but I can't seem to get it to work and I don't see anything wrong. My slice files are:
For the Ice client
and
For the IceRPC server.
I tried playing around with the Uri both on client and server, but here is what I have right now:
Server:
Client:
The errors I get on the client are always on the
greeter = VisitorCenter.GreeterPrx.checkedCast(base)
line and are either:( what these snippets produce ) I also managed to get ObjectNotExistException errors (although I don't quite remember which combination of parameters gave me these errors).
Some information that might be useful:
The IceRPC server is running on net8.0 and IceRpc 0.3.0 The Ice client is running on python3 and Ice 3.7.9.1
Is there something I'm missing?