Comments (11)
zinx:1.1.2版本,1.1.0 无任何问题
你的协议是什么样的?如果没有设置解码器,默认是TLV格式协议.最好附上你的测试数据
from zinx.
你的协议是什么样的?如果没有设置解码器,默认是TLV格式协议.最好附上你的测试数据
from zinx.
我解释一下,这里存在两个问题:
1、client.GetPacket().Pack,这里的Pack使用的是小端模式,但是服务器默认是大端;
2、这里的Pack封装的是LTV模式,但是服务器默认是是TLV,请一定注意写msgID和dataLen的前后顺序
代码如下:
func Pack(msg ziface.IMessage) ([]byte, error) {
dataBuff := bytes.NewBuffer([]byte{})
//写msgID
if err := binary.Write(dataBuff, binary.BigEndian, msg.GetMsgID()); err != nil {
return nil, err
}
//写dataLen
if err := binary.Write(dataBuff, binary.BigEndian, msg.GetDataLen()); err != nil {
return nil, err
}
//写data数据
if err := binary.Write(dataBuff, binary.BigEndian, msg.GetData()); err != nil {
return nil, err
}
return dataBuff.Bytes(), nil
}
func main() {
client := znet.NewClient("127.0.0.1", 8999)
client.SetOnConnStart(func(conn ziface.IConnection) {
//msg, _ := client.GetPacket().Pack(zpack.NewMsgPackage(0, []byte("hello")))
msg, _ := Pack(zpack.NewMsgPackage(0, []byte("hello")))
//请注意,msg数据在zpack中使用的小端模式,但是服务器默认是大端哦
zlog.Ins().DebugF("send msg %s \n", hex.EncodeToString(msg))
_, err := conn.GetConnection().Write(msg)
fmt.Println(err)
})
client.Start()
select {}
}
from zinx.
请阅读aceld/[email protected]/examples/LTVDecoder.go文件,专门针对LTV协议格式做出的解释与处理
from zinx.
PackData 下面的Pack 是否需要更新一下呢,他这里还是使用的先DataLen 在msgID的
from zinx.
我使用protobuf来传输数据的时候,他解析出来也是存在问题的。proto unmarshal err:proto: cannot parse invalid wire-format data,我通过断点查看,MsgData其实并没有把MsgId和DataLen去除,还是在包里面的,这样的话就等于还需要自己重新解析一次
这是我处理数据的地方
from zinx.
我看了,使用这个解码采用的response来读取数据没问题,但是如果不采用的话根本就无法读取到数据,只能读取到MsgId和DataLen
from zinx.
@clukboy 确实,,我们应该先兼容一下之前的,这个原因是近期我们新增了一套解码器,可以提供自定义报文格式的,可能在之前暴露出来的接口没有兼容好,你可以先用下v1.1.0, 这几天我们会兼容下之前的接口,之后会打个tag,在这里回复。
from zinx.
使用v1.1.3版本,解决以上问题
from zinx.
使用v1.1.3版本,解决以上问题
还是不行,数据还是没有解析,应该默认是不初始化解码器才是正确的,由用户来初始化解码器就行了
from zinx.
使用v1.1.3版本,解决以上问题
还是不行,数据还是没有解析,应该默认是不初始化解码器才是正确的,由用户来初始化解码器就行了
你这个地方说的没错,但是为了兼容以前版本,所以才设置默认。如果你不想要默认的,可以自行设置s.SetDecoder(nil)
使用v1.1.5版本目前存在的问题应该都已经解决!
from zinx.
Related Issues (20)
- websocket并发写入问题 HOT 2
- [fix]文件名拼写错误 HOT 1
- 项目自定义 flag 参数不能解析 HOT 4
- ShardLockMaps的GetShard方法内应该使用结构体中的shareKeyFunc而非fnv32 HOT 2
- 目前版本又会出现#161 的问题? HOT 6
- 有关责任链的设计疑问 HOT 1
- note: "go.1.16+ //go:build comment without // +build comment" error.
- 异步问题 HOT 3
- 建议增加设置golang net的默认keepalive的方法 HOT 1
- 请教zinx必须通过msgid处理消息吗 HOT 3
- 如果在同一台服务器初始化了两个server,初始化服务器顺序不同,导致routerslice问题 HOT 1
- 请问怎么构建一个websocket的client? HOT 1
- 关闭服务时,书写重复代码 HOT 1
- RouterSlices中Handlers的意义还存在逻辑错误 HOT 1
- connection.go SendBuffMsg函数代码重复 HOT 3
- clone函数切片应该使用深拷贝 HOT 5
- Request stepLock and Chain.Proceed
- 在zinx中网关节点做转发协议该如何配置路由? HOT 3
- How to send mesaage from server to cleint? HOT 2
- 支持TLS吗? HOT 1
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 zinx.