#1 2018-02-06 12:43:19

jaclas
Member
Registered: 2014-09-12
Posts: 215

Client-server contract incompatibilty

I get exception:

TServiceFactoryClient.Create(): server''s IMyService contract differs from 
client''s: expected ["1"], received [1] - 
you may need to upgrade your 1.0.0.219 client to match  server expectations'

But see screen from debug session (mORMot.pas)

uR5XXilJ.png

This is my mistake or mORMot has problem? :-)


ps. latest mORMot, Delphi Tokyo

Last edited by jaclas (2018-02-06 12:43:39)

Offline

#2 2018-02-06 17:46:14

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Client-server contract incompatibilty

Are you sure both server and client has the same mORMot revision?

Offline

#3 2018-02-06 18:25:18

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Client-server contract incompatibilty

If you have changed the definition of IMyService, you have to **compile** both the server and client programs.
All, I mean all, all of the time I got a "contract" error was the above mentioned reason.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#4 2018-02-06 19:24:25

Junior/RO
Member
Registered: 2011-05-13
Posts: 210

Re: Client-server contract incompatibilty

Yeah you need to recompile and redeploy both. That happened here too.

Offline

#5 2018-02-06 21:50:22

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: Client-server contract incompatibilty

I always recompile server and client.

But why ContractExpected value has quoted chars around "1"? See Watch List and values of compared variables.

Offline

#6 2018-02-06 23:03:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Client-server contract incompatibilty

The contract is expected to be a string, IIRC.

Offline

#7 2018-02-07 09:51:16

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: Client-server contract incompatibilty

Client side:

    fServiceFactory := fClient.ServiceRegister(TypeInfo(IMyInterface), sicShared, '2') as TServiceFactoryClient;

server side:

  sf := ServiceRegister(fMyService as TInterfacedObject, [TypeInfo(IMyService)], '2');
  sf.ContractExpected := '2';

and I still get exception:

{"Message":"TServiceFactoryClient.Create(): server's IMyService 
contract differs from client's: expected [\"2\"], received [2] - you may need to upgrade your 1.0.0.221 client to match  server expectations"}

Why? Where I make mistake?

Offline

#8 2018-02-07 10:06:57

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: Client-server contract incompatibilty

BtdPrwv5.png

And I found problematic place, in constructor:

constructor TServiceFactory.Create(aRest: TSQLRest; aInterface: PTypeInfo; 
                                aInstanceCreation: TServiceInstanceImplementation; const aContractExpected: RawUTF8);

See:

SfiMe1yl.png

Last edited by jaclas (2018-02-07 10:23:01)

Offline

#9 2018-02-07 12:29:29

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: Client-server contract incompatibilty

I found on server side:

NSZp6rv8.png


But I have it in the code for a very long time! And maybe the last versions of the mORMot have changed something here...

Last edited by jaclas (2018-02-07 12:32:41)

Offline

#10 2018-02-07 13:12:54

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Client-server contract incompatibilty

Just get rid of this line.

IIRC ServiceRegister() did already set the ContractExpected value from the '1' supplied parameter - with the quotes.
See TServiceFactory.Create.

Also check https://synopse.info/fossil/info/152edc748c33068b for the client side.

Offline

#11 2018-02-08 14:04:14

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: Client-server contract incompatibilty

Ok, I remove this line, but I have a doubt and a question!

When I create TServiceFactoryServer object and specify the contract in the constructor:

  sf := ServiceRegister(fMyService as TInterfacedObject, [TypeInfo(IMyService)], '2');

then in ContractExpected property I have value: "2" (with quote chars)

sf.ContractExpected is equal "2"

But (!) when I use setter:

  sf.ContractExpected := '2';

then property is set to a different value! ContractExpected property has a: 2 (without quote chars!)

sf.ContractExpected is equal 2

This is IMHO a incorrect behavior, the value set by the constructor should be the same as set by property.

Last edited by jaclas (2018-02-08 14:05:22)

Offline

#12 2018-02-08 15:30:11

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Client-server contract incompatibilty

We should simply remove the property setter to avoid confusion...

Offline

#13 2018-02-08 21:29:52

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: Client-server contract incompatibilty

Thx Arnaud!

Offline

Board footer

Powered by FluxBB