Results 1 to 2 of 2

Thread: Qt app. DNS resolution fails when started on system startup using upstart

  1. #1
    Join Date
    May 2010
    Qt products

    Default Qt app. DNS resolution fails when started on system startup using upstart

    Hi all,

    I have currently using Ubuntu Linux 10.04 LTS (x86-64), using Qt from Ubuntu's software distribution (Qt v4.6.2).

    I have an application that needs to start on system startup. So I am using Ubuntu's upstart to start the the application.

    This application performs a DNS resolution (hostname to IP) which is failing if started using upstart, but works once I run the application on Terminal when I log in; I've made sure the upstart job starts on Ubuntu's Run Level 2.

    The specific Qt API I am using is QHostInfo::fromName. The specific error (obtained via QHostInfo.error() and QHostInfo.errorString() instance methods) is Host not found.

    I thought it was a Ubuntu's run level problem, so I try to issue a dig command in the upstart job to see if that works; dig works fine, just my app. doesn't.

    Another strange thing. Even if the DNS resolution works (when I run it on Terminal after logging in), the error message from QHostInfo is Unknown error

    I have attached the Qt Creator project with the section of app. in question (binary to be placed in /usr/local/bin for this upstart script). As well I've attached my Ubuntu upstart script (to be placed in /etc/init and its I/O streams directed to /var/log/qthostnameres/log.log - a file which should be created beforehand).

    I've also attempted to run the app. as a non-admin. user using su but get the same error result.

    Any past experiences, solutions, suggestions? Have I done something really silly here?

    Attached Files Attached Files

  2. #2
    Join Date
    Feb 2008
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5

    Default Re: Qt app. DNS resolution fails when started on system startup using upstart

    Works like a charm on my Debian Sid box. I have been putting off migrating to a dependency based boot system for no apparent reason, so I decided to take the plunge and test your app at the same time.
    From log.log
    Qt Code:
    1. DEBUG from main method - Hostname to resolve is ""
    2. DEBUG from HostnameResolver::Dns2ip - fromName result: "Unknown error"
    3. DEBUG from HostnameResolver::Dns2ip - Number of IP addresses: "4"
    4. "0" - ""
    5. "1" - ""
    6. "2" - ""
    7. "3" - ""
    To copy to clipboard, switch view to plain text mode 

    Regarding the "Unknown error", from the docs:
    QString QHostInfo::errorString () const
    If the lookup failed, this function returns a human readable description of the error; otherwise "Unknown error" is returned.
    QHostInfo::error() returns 0 which is "QHostInfo::NoError".

Similar Threads

  1. Qt app in linux startup
    By qtlinuxnewbie in forum Newbie
    Replies: 8
    Last Post: 2nd March 2010, 18:37
  2. QT Creator crashed on startup
    By eloos in forum Qt Tools
    Replies: 13
    Last Post: 20th November 2009, 08:50
  3. Replies: 5
    Last Post: 19th September 2008, 15:24
  4. Switching between console and GUI on startup
    By EricF in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 19:03
  5. QToolBar go away! On startup anyway.
    By bitChanger in forum Qt Programming
    Replies: 1
    Last Post: 10th February 2006, 18:22

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.