Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Provide programmatic access to the remote debugger port #13432

Closed
nex3 opened this issue Jul 22, 2015 · 2 comments
Closed

Provide programmatic access to the remote debugger port #13432

nex3 opened this issue Jul 22, 2015 · 2 comments

Comments

@nex3
Copy link

nex3 commented Jul 22, 2015

In the Dart test runner, we run PhantomJS as a subprocess for automatic testing. We want to support remote debugging, but the way our infrastructure works means it doesn't make sense for users to explicitly pass in a port. If we pass in a particular port number, that runs the risk of collisions or race conditions, so we'd like to pass in 0 to get the OS to auto-assign a free port. Unfortunately, once this happens, there's no way to figure out the actual port that was bound.

It would be great if the API would expose this port somehow if it's bound (for example, phantom.remoteDebuggerPort). This could also be useful for PhantomJS scripts reacting to the existence of a remote debugger or presenting the user with a link to one.

@iradul
Copy link
Contributor

iradul commented Jul 23, 2015

This is doable but you'll have to modify some core webkit classes so I don't know if that will be acceptable, but you can always fork. Anyway here you can catch the actual port number:

void InspectorServerQt::listen(quint16 port)
{
    if (m_tcpServer)
        return;

    m_tcpServer = new QTcpServer();
    m_tcpServer->listen(QHostAddress::Any, port);
    connect(m_tcpServer, SIGNAL(newConnection()), SLOT(newConnection()));
    // this will give you the actual port number: m_tcpServer->serverPort()
}

@vitallium
Copy link
Collaborator

Landed in master (14d53ce). Thanks!

iradul added a commit to iradul/phantomjs that referenced this issue Jan 14, 2016
Also print warning when remote debugger fails to bind to the specified
port.

Issue: ariya#13432
igorshapiro pushed a commit to WiserSolutions/phantomjs that referenced this issue Sep 29, 2016
Also print warning when remote debugger fails to bind to the specified
port.

Issue: ariya#13432
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants