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

mqant客户端如何集成到cocos creator中? #9

Closed
charmfocus opened this issue Aug 16, 2017 · 8 comments
Closed

mqant客户端如何集成到cocos creator中? #9

charmfocus opened this issue Aug 16, 2017 · 8 comments

Comments

@charmfocus
Copy link

mqant客户端无法集成到cocos creator中,能否提供一个cocos creator版的mqant client

@charmfocus
Copy link
Author

编译成ios版的,运行提示AMQJS0010E localStorage is not supported by this browser.
在mqttws31.js中找到

		if (!("localStorage" in global && global.localStorage !== null)) {
			throw new Error(format(ERROR.UNSUPPORTED, ["localStorage"]));
		}

意思是window对象没有localStorage,在浏览器上调试是OK的,但编译成ios版就出现这个问题

@liangdas
Copy link
Owner

mqttws31.js需要浏览器支持html5的api,可能你的那个不是一个完整的浏览器。cocos creator我没有用过,但如果你是做原生应用的话.可以尝试其他的Javascript mqtt库 见以下网页中http://www.mqant.com/topic/5942638453ad5d474f7eae12
例如
mqtt.js

node_mqtt_client (more information)

IBM-provided PhoneGap / Apache Cordova MQTT plug-in for Android - JavaScript API is identical to Eclipse Paho HTML5 JavaScript

这些库可能不会依赖浏览器中的特性

@charmfocus
Copy link
Author

我找了这个https://github.com/eclipse/paho.mqtt.javascript, 同样的问题,但后来修改了此文件,cocos2d中支持cc.sys.localStorage;做了兼容,并修复部分变量初始化问题,可以连通了。
但现在又有一个新问题,如何对mqtt数据做aes加密,或自己在send时,把body数据进行单独aes加密,服务端进行解密;或用ssl怎么加密(ssl客户端没有证书)。mqant是否有意向集成加密协议?

@liangdas
Copy link
Owner

mqant支持tls加密的,也就是类似https这种,比如websocket协议就支持ws 和wss两种,tcp就支持tls。具体使用在mqant后端只需要在server.conf的gate模块下配置一下申请到的数据签名证书就行了

@charmfocus
Copy link
Author

但这种加密不能防止中间人攻击,客户端不可信,是可以伪造数据发送到服务器的。真正相对安全的传输数据,是需要对数据进行加密的。我准备在send时把body部分的数据进行aes加密,对方收到数据再进行解密,这样客户端的KEY不会破解数据就不会被伪造。
下面这篇文章里有相关数据安全处理的说明
https://www.ibm.com/developerworks/library/iot-trs-secure-iot-solutions2/index.html

@liangdas
Copy link
Owner

https 这种加密本身就很安全呀,全球公司都用,你自己搞加密算法才会漏洞百出

@charmfocus
Copy link
Author

可能你没明白 ,https的话,客户端没加什么证书和服务器进行双向加密,数据包是可以分析的,内容是明文的,是不安全的。

@charmfocus
Copy link
Author

这个问题就到这吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants