当前位置:网站首页>Websocket implementation principle
Websocket implementation principle
2022-06-30 04:24:00 【No bug program yuan】
websocket Same as http and https equally , Belong to tcp Based on the application layer protocol ; need Three handshakes, four waves The process of
Generally speaking , What we use http The protocol can only be requested by the client , The server cannot push data directly and actively , This leads to continuous changes on the server ( Such as chat rooms ) The client side is more complex to obtain ( Such as real-time performance and service side pressure ). therefore ,websocket The agreement came into being
about websocket Agreement for , Both the client and the server can actively push messages , The message content can be either text or binary data . And there is no restriction of homology policy , There is no cross domain problem
websocket The representation of the agreement ws(ws://xxxx.com); image https equally , If encrypted , The identifier is wxs
websocket Handshake
Handshake : Verify that the server supports websocket agreement
1) Create connection , The browser connects to the server , Connection created successfully
2) The browser generates a random string , The browser saves a copy of the random string , Send a copy to the server at the same time ( be based on http The protocol is sent to the server , Will put the string in http The request header is sent to the server )
3) After the server receives the random string , Let it follow the magic string (magic string, Globally recognized fixed string ) Splicing , And then through sha1 The algorithm encrypts and then passes base64 After the coding , Generating ciphertext
4) The server returns the ciphertext to the browser ( The ciphertext cannot be inversely solved )
5) The browser also matches the locally stored random string with magic string A ciphertext is obtained by splicing and encrypting
6) The browser compares the ciphertext sent by the server with the local ciphertext 、 check , If through , It means that both ends use the same magic string, The same encryption method that is used , That is, it can be determined that the server supports websocket agreement , Shake hands with success ; If the verification fails , It means that the server does not support websocket agreement , Handshake failed
边栏推荐
- el-upload上傳文件(手動上傳,自動上傳,上傳進度)
- Grasp grpc communication framework in simple terms
- With the deep integration of cloud platform, the "Xueba" objectscale in the object storage industry is coming
- Unity when entering a string in the editor, escape the input of characters
- 7-3 single source shortest circuit for strange play upgrade
- FortiGate firewall configuration link detection link monitor and status query
- Qt Creator 8 Beta2发布
- [cloud native] AI cloud development platform - Introduction to AI model foundry (developers can experience AI training model for free)
- Myrpc version 5
- How to write a conditional statement to obtain the value of the maximum time in a table using a MySQL statement
猜你喜欢

el-upload上传文件(手动上传,自动上传,上传进度)

OneNote software

什么是光耦电路,实际使用中应该注意些什么?

How to solve the problem of link hyperlinks when trying to link the database?

Machine learning notes

El upload Upload file (Manual upload, Automatic upload, upload progress)
![Blue Bridge Cup: magic cube rotation [Vocational group]](/img/ba/aeae2744f3aaa1052b5af452f990e2.jpg)
Blue Bridge Cup: magic cube rotation [Vocational group]

How to use div boxes to simulate line triangles

《机器人SLAM导航核心技术与实战》第1季:第0章_SLAM发展综述

Day 10 data saving and loading
随机推荐
el-upload上傳文件(手動上傳,自動上傳,上傳進度)
SQL server2005中SUM函数中条件筛选(IF)语法报错
If you encounter problems when using spark for the first time, please ask for help
数据链路层详解
Everyone, Flink 1.13.6, mysql-cdc2.2.0, the datetime (6) class extracted
Myrpc version 6
Sql语句遇到的错误,求解
JS static method
Implementation steps of dynamic proxy
在大厂外包呆了三年,颠覆了我的认知!
How to use div boxes to simulate line triangles
Es2016 key summary
基于ROS的SLAM建图、自动导航、避障(冰达机器人)
7-3 打怪升级 单源最短路
Default value of JS parameter
Project safety and quality
Read / write lock example
Myrpc version 2
About manipulator on Intelligent Vision Group
Error in conditional filter (if) syntax in sum function in SQL Server2005