0 голосов
 
819 просмотров
17.05.2021 / 00:37  wRadchuk

Spring Boot Websocket Ошибка при подключении

Не могу подключится к серверу:
  1. 2021-05-17 01:09:26.651  INFO 7072 --- [io-25565-exec-7] o.apache.coyote.http11.Http11Processor   : Error parsing HTTP request header
  2.  Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
  3.  
  4. java.lang.IllegalArgumentException: Invalid character found in method name [0x160x030x010x020x000x010x000x010xfc0x030x030x02s0xb2X0x910xd20x830xfd0xec0xecr]0xc00x06B0x07L0xac0xb60x92:J0xbb0xccC0xccb0xdf0xd70xf50xc8A]. HTTP method names must be tokens
  5.     at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:417) ~[tomcat-embed-core-9.0.45.jar:9.0.45]
  6.     at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:261) ~[tomcat-embed-core-9.0.45.jar:9.0.45]
  7.     at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.45.jar:9.0.45]
  8.     at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893) ~[tomcat-embed-core-9.0.45.jar:9.0.45]
  9.     at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1707) ~[tomcat-embed-core-9.0.45.jar:9.0.45]
  10.     at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.45.jar:9.0.45]
  11.     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
  12.     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
  13.     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.45.jar:9.0.45]
  14.     at java.base/java.lang.Thread.run(Thread.java:835) ~[na:na]

Пока что грешу на то что дело в отсутствии сертификата, стучусь так:
wss://31.131.66.246:25565/websocket

стучусь тут.

Долго искал как реализовать на Spring Boot сервер с соединением через wss, а не https. Нашел реализацию на левом сайте, так как в офф доке не увидел подобного и всё же не работает. Конект через ws не проходит вобще, ну а через wss ошибка приложена выше.

Вот ссылка на проект.


Каков ваш вердикт уважаемые?
17.05.2021 / 08:49  aNNiMON
А поставь ws и с ним попробуй хоть чего-то добиться. Может что в логах будет или даже ошибка какая-то.
17.05.2021 / 11:35  wRadchuk
Решение

1. You need to create a self-signed SSL certificate. The two most common formats used for keystores are JKS, specific for Java, and PKCS12, an industry standard format. JKS used to be the default choice, but now Oracle recommends to adopt the PKCS12 format. We will use PKCS12 format in the example.

2. Open your command prompt and enter the following command:

keytool -genkeypair -alias tomcat -keyalg RSA -keysize 2048 -storetype PKCS12 -keystore keystore.p12 -validity 3650

3.
17.05.2021 / 11:36  wRadchuk
As an output of this command, you will be asked to enter the password for your keystore.

4. Once your password is accepted, you will be asked some information to enter like first name, last name, city, country but you can skip those.

5. Once you have entered all the required information, a keystore will be created. verify that using the following command:

keytool -list -v -storetype pkcs12 -keystore keystore.p12

6. Now we have SSL Certificate ready, the only thing that is remaining i
17.05.2021 / 11:37  wRadchuk
s changing your application.properties/application.yml in your Spring Boot application.

server.port=xxxxx
security.require-ssl=true
server.ssl.key-store-type=PKCS12
server.ssl.key-store=classpath:keystore.p12
server.ssl.key-store-password=password
server.ssl.key-alias=tomcat

Ссылка на статью

P.S. Незнаю почему но по WS:// не работает, после установки сертификата тот же код заработал н
17.05.2021 / 11:37  wRadchuk
а WSS://

P.P.S. Тема закрыта. Всем спасибо)
Ответы
Ответов нет
Всего: 0

Реклама

Мы в соцсетях

tw tg yt gt