Comments (4)
got it, it turns out a bug inside the code, some magic comes out!
-------------------------------step 1----------------------------------
const socket = io(url, {
transportOptions: {
websocket: {
extraHeaders: {
'x-clientid': 'abc'
}
}
}
});
---------------------------------step 2----------------------------------
in "weapp.socket.io.js" replace
{ "content-type": "application/json" }
with
Object.assign({ "content-type": "application/json" }, r.headers)
from weapp.socket.io.
How NewBee i am!
from weapp.socket.io.
@rzrobert weapp.socket.io not support polling transport
from weapp.socket.io.
@rzrobert @ccckblaze 关于 header 的使用,socket.io 官方文档有给出解释, 在 websokcet transport 模式下无法自定义 header,而且小程序版本的 socket.io 是不支持 polling transport 的。
With extraHeaders
This only works if polling transport is enabled (which is the default). Custom headers will not be appended when using websocket as the transport. This happens because the WebSocket handshake does not honor custom headers. (For background see the WebSocket protocol RFC)
from weapp.socket.io.
Related Issues (20)
- 用了一下,请教! HOT 1
- 服务端我用的2.x版本,这个是否支持呢? HOT 1
- 微信小程序出现bug
- 服务端socket.io @4 能用这个包吗? HOT 9
- 能支持socket.io-client 4.6.1最新版本吗? HOT 2
- WebSocket was closed before the connection was established HOT 4
- Converting circular structure to JSON --> starting at object with constructor 'c' | property 'io' -> object with constructor 'f' | property 'nsps' -> object with constructor 'Object' --- property '//undefined//undefined' closes the circle at JSON.stringify (<anonymous>) at cloneWithData (vendor.js? [sm]:9037) at VueComponent.patch [as __patch__] (vendor.js? [sm]:9050) at VueComponent.Vue._update (vendor.js? [sm]:7359) at VueComponent.updateComponent (vendor.js? [sm]:9118) at Watcher.get (vendor.js? [sm]:7819) at Watcher.run (vendor.js? [sm]:7894) at flushSchedulerQueue (vendor.js? [sm]:7650) at Array.<anonymous> (vendor.js? [sm]:5389) at flushCallbacks (vendor.js? [sm]:5317)(env: Windows,mp,1.06.2307260; lib: 3.1.0)
- 客服端发的消息,服务端会同时收到两条一样的 HOT 1
- 提一个非常实用的小建议:剔除socket.io-client依赖。 HOT 2
- npm 安装使用无效, 用源码编译出来的js直接使用可以.
- IOS 11.2 不支持...扩展ES6语法 HOT 2
- 小程序重复退出、再次进入操作socket连接报错:websocket was closed before the connection was established
- 3.0.0版本在微信小程序分包里面调用connect时,真机上预览、体验版均会报错
- 目前是不是不支持polling模式? HOT 2
- TypeError: io is not a function HOT 2
- 能不能出一个client版本是2.X的版本 HOT 1
- 想请教这个包的目的到底什么? HOT 3
- 为什么yarn install 和npm install生成的weapp.socket.io.js不一样呢?
- 请教python flask-socketio不兼容这个微信小程序js文件,报错"GET /socket.io/?EIO=4&transport=websocket HTTP/1.1" 400 ,是本项目依赖的socket.io-client版本太低了吗?
- 请问支持支付宝小程序吗? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from weapp.socket.io.