Modified

datastore['RPORT'] =  redir_port

with

connect(true, {'RPORT' => redir_port})