krowinski / php-mysql-replication

Pure PHP Implementation of MySQL replication protocol. This allow you to receive event like insert, update, delete with their data and raw SQL queries.
MIT License
323 stars 98 forks source link

[ErrorException] unpack(): Type i: #28

Closed leoliuxd closed 7 years ago

leoliuxd commented 7 years ago

I came across a fetal error:

[ErrorException]
unpack(): Type i: not enough input, need 4, have 2

only in src/MySQLReplication/BinLog/BinLogServerInfo.php there are same function call,

self::$serverInfo['connection_id'] = unpack('I', $data[$i] . $data[++$i] . $data[++$i] . $data[++$i])[1];

krowinski commented 7 years ago

Hi, what version of mysql are u using ? and OS ?

select version();

leoliuxd commented 7 years ago

5.6.16-log

leoliuxd commented 7 years ago

my client is Mac OS x10.12.5 , PHP 7.0.14

leoliuxd commented 7 years ago

i just downgrade php toPHP 5.6.30 and [ErrorException]
unpack(): Type I: not enough input, need 4, have 0

krowinski commented 7 years ago

Tested php example/dump_events.php on OSX 10.12.6 mysql installed from homebrew 5.6.37-log no problems there. Did you add https://github.com/krowinski/php-mysql-replication#mysql-server-settings to my.cnf ? Show me you code do u use files from example ?

leoliuxd commented 7 years ago

Maybe i have found what's the problem, it seems that the mysql character_set affects the parse of binlog. The decoder should be the same with mysql character_set. Thanks ^^

krowinski commented 7 years ago

what charset u use in binlog ?

leoliuxd commented 7 years ago

I set that to gbk, but the problem still exist. Some column is set BLOB type.