Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

websocket server send text error 1002 #7986

Closed
baichangda opened this issue Nov 10, 2023 · 5 comments
Closed

websocket server send text error 1002 #7986

baichangda opened this issue Nov 10, 2023 · 5 comments
Assignees
Labels
4.x Version 4.x bug Something isn't working P2 websocket WebSocket in Helidon
Milestone

Comments

@baichangda
Copy link

baichangda commented Nov 10, 2023

Environment Details

implementation group: 'io.helidon.webserver', name: 'helidon-webserver', version: '4.0.0'
implementation group: 'io.helidon.webserver', name: 'helidon-webserver-static-content', version: '4.0.0'
implementation group: 'io.helidon.webserver', name: 'helidon-webserver-websocket', version: '4.0.0'


Problem Description

helidon se websocket server send text to client in onOpen function produce client error 1002

Steps to reproduce

websocket server code like this
image
webcoekt client code like this
image

1、js websocket connect to helidon websocket server succeed
2、in onOpen(...) callback send msg to client、send function is 'WsSession send(String text, boolean last)'
3、then js websocket client error
image

@baichangda baichangda changed the title websocket send error 1002 websocket server send text error 1002 Nov 10, 2023
@m0mus m0mus added bug Something isn't working websocket WebSocket in Helidon 4.x Version 4.x P2 labels Nov 13, 2023
@spericas
Copy link
Member

spericas commented Nov 14, 2023

@baichangda Seems like you're not showing the call to send(String, boolean) in your onOpen, right? Do you have sample code that matches your problem description? Is that in your WsSession class?

@baichangda
Copy link
Author

@spericas there is call stack image
image
image
image
image

@spericas
Copy link
Member

@baichangda I'm not able to reproduce your problem using Helidon 4.0.0 and Chrome 119.0.6045.123. Please find a simple WS app attached that you can build and run as a server. For the client part, I'm just pasting some JavaScript code into the browser's console:

ws = new WebSocket("ws://localhost:8080/ws")
ws.onopen = function (evt) {
    console.log("onopen " + evt.type);
}
ws.onmessage = function (evt) {
    console.log("onmessage " + evt.data)
    ws.send("Hello to you")
}
ws.onclose = function (evt) {
    console.log("onclose " + evt.code)
}

The server and client outputs are all as expected, without any errors. Have your tried other clients? Perhaps you can use this simple app and modify it to reproduce the issue.

quickstart-se.zip

@baichangda
Copy link
Author

@spericas
i try send simple string, there is no problem
but complex string 、for example json like this、ws client will get error、you can try it
"{\"@class\":\"com.bcd.share.support_parser.impl.gb32960.data.VehicleRunData\",\"collectTime\":1686211816000,\"vehicleBaseData\":{\"vehicleStatus\":1,\"chargeStatus\":3,\"runMode\":1,\"vehicleSpeed\":6.4,\"totalMileage\":85.0,\"totalVoltage\":388.0,\"totalCurrent\":11.299988,\"soc\":28,\"dcStatus\":1,\"gearPosition\":46,\"resistance\":8192,\"pedalVal\":0,\"pedalStatus\":0},\"vehicleMotorData\":{\"num\":1,\"content\":[{\"no\":1,\"status\":1,\"controllerTemperature\":49,\"rotateSpeed\":443,\"rotateRectangle\":1.5,\"temperature\":34,\"inputVoltage\":389.0,\"current\":0.0}]},\"vehiclePositionData\":{\"status\":0,\"lng\":121.193701,\"lat\":31.28577},\"vehicleLimitValueData\":{\"maxVoltageSystemNo\":1,\"maxVoltageCode\":9,\"maxVoltage\":3.611,\"minVoltageSystemNo\":1,\"minVoltageCode\":55,\"minVoltage\":3.604,\"maxTemperatureSystemNo\":1,\"maxTemperatureNo\":1,\"maxTemperature\":29,\"minTemperatureSystemNo\":1,\"minTemperatureNo\":4,\"minTemperature\":28},\"vehicleAlarmData\":{\"maxAlarmLevel\":3,\"alarmFlag\":136071,\"chargeBadNum\":0,\"chargeBadCodes\":[],\"driverBadNum\":0,\"driverBadCodes\":[],\"engineBadNum\":0,\"engineBadCodes\":[],\"otherBadNum\":0,\"otherBadCodes\":[]},\"vehicleStorageVoltageData\":{\"num\":1,\"content\":[{\"no\":1,\"voltage\":388.0,\"current\":11.299988,\"total\":108,\"frameNo\":1,\"frameTotal\":108,\"singleVoltage\":[3.608,3.609,3.61,3.609,3.609,3.608,3.608,3.61,3.611,3.608,3.609,3.61,3.608,3.608,3.609,3.61,3.61,3.609,3.608,3.61,3.608,3.61,3.61,3.608,3.607,3.609,3.607,3.609,3.607,3.609,3.611,3.609,3.609,3.609,3.608,3.608,3.607,3.607,3.608,3.607,3.607,3.607,3.609,3.607,3.608,3.607,3.609,3.607,3.607,3.607,3.608,3.608,3.609,3.609,3.604,3.608,3.608,3.607,3.607,3.605,3.606,3.606,3.608,3.609,3.607,3.608,3.607,3.608,3.607,3.608,3.607,3.606,3.609,3.605,3.608,3.606,3.608,3.607,3.606,3.606,3.607,3.605,3.607,3.607,3.604,3.607,3.606,3.606,3.607,3.607,3.607,3.607,3.606,3.607,3.606,3.607,3.604,3.607,3.607,3.606,3.606,3.607,3.607,3.607,3.606,3.606,3.606,3.606]}]},\"vehicleStorageTemperatureData\":{\"num\":1,\"content\":[{\"no\":1,\"num\":12,\"temperatures\":[29,29,29,28,29,28,28,28,29,28,29,28]}]}}"

@spericas
Copy link
Member

Issue has been fixed, will be available in release 4.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x bug Something isn't working P2 websocket WebSocket in Helidon
Projects
Archived in project
Development

No branches or pull requests

3 participants