Orange-OpenSource / wamp.rt

A WAMP V2 nodejs router
MIT License
34 stars 22 forks source link

Session ID string not comform specification #7

Open ErwinSteffens opened 9 years ago

ErwinSteffens commented 9 years ago

We're using Wamp.rt as our server wamp implementation and Jawampa (https://github.com/Matthias247/jawampa) as a client. There is a small incompatibility between the two.

Wamp.rt creates a session ID as a string value in the wamp messages. The Jawampa implementation parses the JSON message and checks if the ID can be converted to a long. This means it needs to be a number and therefore the message parsing fails and the connection is dropped.

When looking at the Wamp spec it says:

These are identified in WAMP using IDs that are integers between (inclusive) 0 and 2^53 (9007199254740992):

The reason to choose the specific upper bound is that 2^53 is the largest integer such that this integer and all (positive) smaller integers can be represented exactly in IEEE-754 doubles. Some languages (e.g. JavaScript) use doubles as their sole number type. Most languages do have signed and unsigned 64-bit integer types which both can hold any value from the specified range. For reference, the following is a complete list of usage of IDs in the three categories for all WAMP Messages (see subsequent chapters).

When looking at the autobahn client which is also javascript it uses the following code to generate the ID which I think is better.

function newid () {
   return Math.floor(Math.random() * 9007199254740992);
}
ghost commented 9 years ago

You're right. I don't have much time right now to change this, but feel free to send a patch.