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

Uninitialized string offset #61

Closed
rajeshafor opened this issue Mar 14, 2018 · 4 comments
Closed

Uninitialized string offset #61

rajeshafor opened this issue Mar 14, 2018 · 4 comments

Comments

@rajeshafor
Copy link

Notice: Uninitialized string offset: 0 in C:\xampp\htdocs\websockets\phpMQTT.php on line 121

Notice: Uninitialized string offset: 0 in C:\xampp\htdocs\websockets\phpMQTT.php on line 125

Notice: Uninitialized string offset: 3 in C:\xampp\htdocs\websockets\phpMQTT.php on line 125
Fail or time out.

I'm new to MQTT. Please give solution for it.

@ghost
Copy link

ghost commented Aug 29, 2018

I'm also experiencing this and trying to track it down. It looks like $this->read() isn't getting any data from the stream.

@kingtiwns
Copy link

phpmqtt only support mqttv3.1 ,not support v3.1.1,you must modify code

//MQTT v3.1.1协议名称长度 4
$buffer .= chr(0x00); $i++;
$buffer .= chr(0x04); $i++;
// 4D 51 54 54 mqtt v3.1.1 协议名称
// 4D 51 49 73 64 70 mqtt v3.0 协议名称
$buffer .= chr(0x4d); $i++;
$buffer .= chr(0x51); $i++;
$buffer .= chr(0x54); $i++;
$buffer .= chr(0x54); $i++;

	//mqtt v3.1.1 协议名称 版本号
	$buffer .= chr(0x04); $i++;

@taroyutao
Copy link

taroyutao commented Jan 12, 2019

@kingtiwns thanks for your great advice.

具体调整如下,是把下面的源码部分

	$buffer .= chr(0x00); $i++;
	$buffer .= chr(0x06); $i++;
	$buffer .= chr(0x4d); $i++;
	$buffer .= chr(0x51); $i++;
	$buffer .= chr(0x49); $i++;
	$buffer .= chr(0x73); $i++;
	$buffer .= chr(0x64); $i++;
	$buffer .= chr(0x70); $i++;
	$buffer .= chr(0x03); $i++;

整体替换为下面的形式即可:

	$buffer .= chr(0x00); $i++;
	$buffer .= chr(0x04); $i++;
	$buffer .= chr(0x4d); $i++;
	$buffer .= chr(0x51); $i++;
	$buffer .= chr(0x54); $i++;
	$buffer .= chr(0x54); $i++;
	$buffer .= chr(0x04); $i++;

@bluerhinos
Copy link
Owner

I am restarting this project so having a clear out of old issues (If you believe this is still valid please reopen)

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

4 participants