关闭Websockets连接

I am using Ratchet in combination with autobahnjs. I know how to close the connection on server side (by calling "close()" on the connection), but how would I be able to close the connection also on client side?

If I only close it on server side, autobahnjs will try to reconnect to the websocket even though I just kicked him out of his connection on server side.. Before kicking him out, I send a last message to the client with a flag "close" => true, afterwards I want to close the autobahnjs connection.

I thought of something like "ab.close() or ab.disconnect()", but close won't stop autobahnjs from trying to reestablish a connection and disconnect is not a known function.

have you tried voiding it?

var conn = ab.(.....)

and when you get the flag

function closeConnection(){
    conn = null;
}

this way the connection elemant is voided and is not able of reopening the connection.

I've been using Ratchet Server for my App Messenger, though I use native Javascript with it (no autobahn), I use

conn.close()

to close the client connection.