websocket session.logon is not working: {“code”:-1022,“msg”:“Signature for this request is not valid.”}

I keep receiving: {“code”:-1022,“msg”:“Signature for this request is not valid.”}

        var timestamp = Instant.now().toEpochMilli();

        var signatureItem = "timestamp=" + timestamp;
        var signature = BinanceAuthUtil.generateSignature(signatureItem);

        var logonJson = """
            {
              "id": "%s",
              "method": "session.logon",
              "params": {
                "apiKey": "%s",
                "signature": "%s",
                "timestamp": %d
              }
            }
            """.formatted(id, API_KEY, timestamp, signature);

So, for session.logon, should signature be only timestamp? I tried with multiple versions, by signing entire request, specific parameters - but I still keep getting the error.

I use the Ed25519 key.

Any idea why this could happen?

No. Your signatureItem should include apiKey as well.

All parameters sent in "params" (except for the "signature" itself) should be included in the string you sign for authentication.