def METHOD_NAME(proto_ver):
    global connect_packet, connack_packet
    if proto_ver == 4:
        bridge_protocol = "mqttv311"
        proto_ver_connect = 128+4
    else:
        bridge_protocol = "mqttv50"
        proto_ver_connect = 5
    (port1, port2) = mosq_test.get_port(2)
    conf_file = os.path.basename(__file__).replace('.py', '.conf')
    write_config(conf_file, port1, port2, bridge_protocol)
    rc = 1
    keepalive = 60
    client_id = socket.gethostname()+".bridge_sample"
    connect_packet = mosq_test.gen_connect(client_id, keepalive=keepalive, clean_session=False, proto_ver=proto_ver_connect)
    connack_packet = mosq_test.gen_connack(rc=0, proto_ver=proto_ver)
    client_connect_packet = mosq_test.gen_connect("pub-test", keepalive=keepalive, proto_ver=proto_ver)
    client_connack_packet = mosq_test.gen_connack(rc=0, proto_ver=proto_ver)
    ssock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    ssock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    ssock.settimeout(4)
    ssock.bind(('', port1))
    ssock.listen(5)
    broker = mosq_test.start_broker(filename=os.path.basename(__file__), port=port2, use_conf=True)
    try:
        (bridge, address) = ssock.accept()
        bridge.settimeout(2)
        sock = mosq_test.do_client_connect(
            client_connect_packet, client_connack_packet,
            port=port2,
        )
        rc = inner_test(bridge, sock, proto_ver)
        sock.close()
        bridge.close()
    except mosq_test.TestError:
        pass
    finally:
        os.remove(conf_file)
        try:
            bridge.close()
        except NameError:
            pass
        broker.terminate()
        broker.wait()
        (stdo, stde) = broker.communicate()
        ssock.close()
        if rc:
            print(stde.decode('utf-8'))
            exit(rc)