Closed Hayk985 closed 6 years ago
From server they said that they have an exception like this SocketProtocolError: Client pong timed out. I have no problem with access and refresh tokens. And the internet connection is great, if I have an internet connection problem, I can't to connect. But I'm connecting successful.
Yes and one more thing too. I moved the socket.connect() method after the listener and socket.on(), and now in debug mode it not gives exception like "socket = no such instance field: 'val$socket' ".
Sure, I will take a look at it @hyko
On Apr 13, 2018 9:19 PM, "Hayko985" notifications@github.com wrote:
From server they said that they have an exception like this SocketProtocolError: Client pong timed out. I have no problem with access and refresh tokens. And the internet connection is great, if I have an internet connection problem, I can't to connect. But I'm connecting successful.
Yes and one more thing too. I moved the socket.connect() method after the listener and socket.on(), and now in debug mode it not gives exception like "socket = no such instance field: 'val$socket' ".
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sacOO7/socketcluster-client-java/issues/28#issuecomment-381178355, or mute the thread https://github.com/notifications/unsubscribe-auth/AP8vSSpn8BJ4Iv0Qj6bkhJ6XOk1yZezCks5toMjvgaJpZM4TTcDe .
Thank you very much, please help me if you can)) @sacOO7
If you want I can give you my vk)))
@sacOO7 Hi)) How are you? Please can you help me to fix this problem, tomorrow is the last day, and if i can't do this, they will not bring me to work. So please, help me if you can)) Thank you.
@sacOO7 Here is my vk, you can connect with me)) https://vk.com/id192526595
Hi @hyko, sorry for late reply. Little busy those days. Will get back to you for sure (today night ...., Probably after 2-3 hours)
On Apr 15, 2018 4:44 PM, "Hayko985" notifications@github.com wrote:
@sacOO7 https://github.com/sacOO7 Here is my vk, you can connect with me)) https://vk.com/id192526595
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sacOO7/socketcluster-client-java/issues/28#issuecomment-381398311, or mute the thread https://github.com/notifications/unsubscribe-auth/AP8vSc8w5GecHxhtp2mnkwxPVW4t_1cbks5toyuPgaJpZM4TTcDe .
@sacOO7 hey bro) I think you can't help me today. If you can't, then can you help me tomorrow, but soon? And how can I connect with you? Any vk, whatsapp or something else.
Hi @Hayko985, Can you explain for which event are you exactly trying to listening to?
Sending auth data is not supposed to be inside listener
Instead before connecting call socket.setAuthToken("Your JWT token here")
You can see that method here https://github.com/sacOO7/socketcluster-client-java/blob/master/src/main/java/io/github/sac/Socket.java#L90
Please post here context of your problem as well as little server code that sends data so that I can understand exact problem. You can email me your context for the code if you do not want to post it here...
Ok, so when I'm giving my jsonobject to that data, instead I need to use setAuthToken. I'm listening to connect event. I'm beginner yet in sockets)) Server says that client not sends pong. What is this pong and how to send it?
Yeah and I have no the server code. I'm doing only the client part)
@sacOO7 Hi) How are you? I done socket.setAuthToken("Your JWT token here"), but that not helped. Server says that client not sends pong. So you know what is that pong and how to send it?
Hi @Hayko, if you are not writing any server code, you don't need to set auth token. You can check example working code here https://github.com/sacOO7/socketcluster-client-java/blob/master/src/main/java/Main.java
On Apr 16, 2018 1:02 PM, "Hayko985" notifications@github.com wrote:
@sacOO7 https://github.com/sacOO7 Hi) How are you? I done socket.setAuthToken("Your JWT token here"), but that not helped. Server says that client not sends pong. So you know what is that pong and how to send it?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sacOO7/socketcluster-client-java/issues/28#issuecomment-381506012, or mute the thread https://github.com/notifications/unsubscribe-auth/AP8vSXSkZbK7VB5mGOkFUuBDvHGIn4g9ks5tpEkIgaJpZM4TTcDe .
Generally auth token is set by server itself, you will receive it and save it.Then reuse it using set auth token method. You will receive token in onsetAuthtoken callback, there you can save it and use it again.
On Apr 16, 2018 1:10 PM, "Sachin Shinde" sachinshinde7676@gmail.com wrote:
Hi @Hayko, if you are not writing any server code, you don't need to set auth token. You can check example working code here https://github.com/ sacOO7/socketcluster-client-java/blob/master/src/main/java/Main.java
On Apr 16, 2018 1:02 PM, "Hayko985" notifications@github.com wrote:
@sacOO7 https://github.com/sacOO7 Hi) How are you? I done socket.setAuthToken("Your JWT token here"), but that not helped. Server says that client not sends pong. So you know what is that pong and how to send it?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sacOO7/socketcluster-client-java/issues/28#issuecomment-381506012, or mute the thread https://github.com/notifications/unsubscribe-auth/AP8vSXSkZbK7VB5mGOkFUuBDvHGIn4g9ks5tpEkIgaJpZM4TTcDe .
@sacOO7 I done as in this example and in logs it says "Authentication is required (optional)". So in socket.setlistener(new BasicListener{}) there is a method onSetAuthToken(). I need to give here my jwt?
@sacOO7 I'm beginner in this sockets and sorry for disturbing you, but i need your help))
Hi @Hayko985, I am not sure why you are sending auth event to server
Can you put your server URL here? Also before sending data make sure you get connected to the server in response.
@sacOO7 Hi)) After long suffering I'm already sending my pong)) So in server there is no any pong exception. The only issue is now that I'm using oauth2 and I can't to send jwm, I need to send my oauth object, so my access token and refresh token.
Let me show some of the server logs and you'll see the exceptions.
[Warning] AuthTokenInvalidError: jwt malformed at emitOne (events.js:96:13) at Socket.emit (events.js:189:7) at readableAddChunk (_stream_readable.js:176:18) at Socket.Readable.push (_stream_readable.js:134:10) at TCP.onread (net.js:551:20) name: 'error', length: 202, severity: 'ERROR', code: '42883', detail: undefined, hint: 'No operator matches the given name and argument type(s). You might need to add explicit type casts.', position: '497', internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: 'parse_oper.c', line: '728', routine: 'op_error' } newuser info socket is KCtCwozsPkSRE0AE (node:12084) UnhandledPromiseRejectionWarning: Unhandled promise rejection (reje ction id: 6): TypeError: Cannot read property '0' of undefined
So any idea bro? Yeah and thank you very much for that help.
Can you give me the context of your server code? I am not sure how it is working or supposed to work. Normally if you start socketcluster server, on normal mode, you do not require to send JWT.
On Apr 16, 2018 6:31 PM, "Hayko985" notifications@github.com wrote:
@sacOO7 https://github.com/sacOO7 Hi)) After long suffering I'm already sending my pong)) So in server there is no any pong exception. The only issue is now that I'm using oauth2 and I can't to send jwm, I need to send my oauth object, so my access token and refresh token.
Let me show some of the server logs and you'll see the exceptions.
[Warning] AuthTokenInvalidError: jwt malformed at emitOne (events.js:96:13) at Socket.emit (events.js:189:7) at readableAddChunk (_stream_readable.js:176:18) at Socket.Readable.push (_stream_readable.js:134:10) at TCP.onread (net.js:551:20) name: 'error', length: 202, severity: 'ERROR', code: '42883', detail: undefined, hint: 'No operator matches the given name and argument type(s). You might need to add explicit type casts.', position: '497', internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: 'parse_oper.c', line: '728', routine: 'op_error' } newuser info socket is KCtCwozsPkSRE0AE (node:12084) UnhandledPromiseRejectionWarning: Unhandled promise rejection (reje ction id: 6): TypeError: Cannot read property '0' of undefined
So any idea bro? Yeah and thank you very much for that help.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sacOO7/socketcluster-client-java/issues/28#issuecomment-381591040, or mute the thread https://github.com/notifications/unsubscribe-auth/AP8vSeVd2y1F3QF27xmEZ05F9lr54H-Sks5tpJYjgaJpZM4TTcDe .
I have only the source code of page, so I can send you only the scrypt part.
https://drive.google.com/file/d/17exVT9XVIbZkuZWFwz1ew-Zg8l8-FHgu/view . Here the scrypt part. It need oauth, because in my application I'm doing user authentication with Oauth2. So I'm not using jwt in my app.
I see
On Apr 16, 2018 6:57 PM, "Hayko985" notifications@github.com wrote:
https://drive.google.com/file/d/17exVT9XVIbZkuZWFwz1ew-Zg8l8-FHgu/view . Here the scrypt part. It need oauth, because in my application I'm doing user authentication with Oauth2. So I'm not using jwt in my app.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sacOO7/socketcluster-client-java/issues/28#issuecomment-381598559, or mute the thread https://github.com/notifications/unsubscribe-auth/AP8vSf96L4A2DMmz5HiNIOu5-YvMb1Brks5tpJxBgaJpZM4TTcDe .
Is this server code written by you? or is it a chatroom service... I just want to know if that code is working. If it is working code, then I might be able to give you the solution. I am assuming you already have accessToken and refreshToken available.
This is for chatroom)) Yes I have accessToken and refreshToken. But wait a while because they are doing work on server and now it's unavailable))
Just a quick question... Are you able to connect to server. I believe you should receive connected to server in onconnect function callback. More precisely, Connected to endpoint. Forget code after sc.connectAsync() function.
Just write down this code after sc.connectAsync method call.
JSONObject authObject = new JSONObject();
authObject.put("accessToken", "Your access token here");
authObject.put("refreshToken", "Your refresh token here");
sc.emit("auth", authObject);
Yes of course. Yeah and I changed the connectAsync() to connect() and moved it into thread. So I don't know what's the difference between this two, because it's connects anyway.
Here my new code))
Here my code after adding the JsonObject part
What is sc.on("connect"). You do not need it.
@sacOO7 I saw it in server code, I thought I need it. Ok but what is that method means?
To get whether you get connected or not, you need to register basic listener. I think, you probably need to take a look at documentation on repo( https://github.com/sacOO7/socketcluster-client-java). It will solve most of your problems :+1:
Yeah I done already the basic listener, that not visible in picture)))
Oh I understood. So with socket.on() I can get message from server and with socket.emit() I can send data to server. I'll read the documentation today)) The server not works yet)))
@sacOO7 Ok man, tomorrow I'll try to connect to server, if there will be any excepions, I'll say you. Thank you very much.
@sacOO7 Hi) How are you? So I done something like this as you said, but the server not gets my data, that I'm sending with emit. Watch here.
@sacOO7 Man there's another little problem, I don't know why is it working like this, but when I'm running my app, that not sends data to server, but when I'm doing debug, it sends the data successful, but when it sends there's an error too.
Here the error log. error TypeError: Cannot read property 'username' of undefined at process._tickCallback (internal/process/next_tick.js:103:7) newuser info socket is 08GaAmezm27PcvAD (node:1416) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejec tion id: 3): TypeError: Cannot read property '0' of undefined
@sacOO7 I fixed the username part. When I'm doing debug all works good without any errors in server. But when I'm doing run it says [Warning] InvalidActionError: Cannot subscribe socket to a channel before it has completed the handshake
Yeah I know the problem. Wait for 15-20 mins. Will get back to you on this ...
On Apr 17, 2018 5:53 PM, "Hayko985" notifications@github.com wrote:
@sacOO7 https://github.com/sacOO7 I fixed the username part. When I'm doing debug all works good without any errors in server. But when I'm doing run it says [Warning] InvalidActionError: Cannot subscribe socket to a channel before it has completed the handshake
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sacOO7/socketcluster-client-java/issues/28#issuecomment-381973078, or mute the thread https://github.com/notifications/unsubscribe-auth/AP8vSW6v_gjGQGkYr6pbK_tPUDwHgLUSks5tpd7UgaJpZM4TTcDe .
@sacOO7 Ok I'll wait you bro) Thanks a lot)))
Hi @Hayko985 , the problem is because, you are trying to subscribe before handshake is made with server. I think you should emit auth event inside onConnected callback. It should work.
@sacOO7 Hi)) All works thanks. So one more question too. Is there any watch method in client part?
That's in server part. How can I do this in client part?
I fixed this using channel.onMessage() method... Thank you very very much. If there will be more questions too, I'll ask you.
Since problem is solved, I will close the issue ..
Hi, I'm creating socket client part, and I have a problem in Emitter.Listener. The listener not throws any exception, it only not compiles. SO when I'm doing debug, and I set breakpoint in that callback, it jumps over the call. I have some pictures where I explain my problem very well.
Any ideas why it's not working. It connects well, and the state is OPEN, but in that call I have to send my tokens into server.