Fix undefined or string port parameter

Port may be undefined or a string. In both cases, the chrome API complains