fix reconnect failed after disconnection

the old version can not reconnect after disconnect, so I fix it
I also add the kill ./core in finally block

test on raspberry pi model B and nexus 5