Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
anhhungxadieuuit
Posts: 27
Registered: ‎12-18-2012
My Device: Z10, Playbook
Accepted Solution

Network Error on OS 10.2 build 424

Hey there,

I have some application on BB world, It work normal on OS 10.1 and below.

Yesterday, I have just updated my Z10 to OS 10.2 OTA with build 424 and I have found that my app work not expected.

 

Connect to Internet more slowly and sometimes has TimeOut error when use QNetworkAccessManager.

 

And when use QTcpSocket i get this error:

 

"SYSTEM: QEventDispatcherBlackberry: cannot unregister QSocketNotifier 259
SYSTEM: QEventDispatcherBlackberry: cannot register QSocketNotifier (fd too high) 259"

I can't connect to my Chat Server anymore.

 

2 of my application now could not work expected with new OS 10.2.

 

Did I make some mistake or this is a bug on Offical 10.2 release????????

 

Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Network Error on OS 10.2 build 424

If you build your app to 10.2 does it still happen?


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Contributor
anhhungxadieuuit
Posts: 27
Registered: ‎12-18-2012
My Device: Z10, Playbook

Re: Network Error on OS 10.2 build 424

Sadly, I tried to build with 10.2 but nothing changed.
I thought there are something wrong with my network connection so I have reload device to OS 10.1 and wipe all data on OS 10.2 and result not changed: OS 10.2 get data over internet slowly and get timeout while OS 10.1 not problem, I hope that not issue on 10.2 :smileysad:(((((
BlackBerry Development Advisor
RSperanza
Posts: 142
Registered: ‎03-08-2012
My Device: Z10

Re: Network Error on OS 10.2 build 424

Without seeing your code, it is hard to say what the issue is.  However, the "fd too high" message sticks out as potentially indicating that there is an uninitialized file descriptor being accessed at some point.

 

This OS release is available as an SDK OS release (1793 is available on the developer site) so you may want to try rebuilding the app with a 10.2 target to see if it makes a difference or at least debug the existing 10.1 app on that OS to see if you notice any odd behaviour.

 

If you cannot find anything, sharing excerpts from your networking code here so others can have a look may help  find the issue.

Contributor
anhhungxadieuuit
Posts: 27
Registered: ‎12-18-2012
My Device: Z10, Playbook

Re: Network Error on OS 10.2 build 424

My code very simple, create connection by QNetworkAccessManager

 

HttpRequest::HttpRequest() :
   QObject(), isSkipNetWorkError(false), reply(NULL) {
        managerConnection = new QNetworkAccessManager(this);
        QObject::connect(managerConnection, SIGNAL(finished(QNetworkReply*)), this, SLOT(onRequestFinished(QNetworkReply*)));
}

 and send request with URL:

void HttpRequest::sendRequest(QUrl& Url) {
        QNetworkRequest request(Url);
        request.setRawHeader("User-Agent", "ZingMe");
        request.setRawHeader("Accept-Encoding", "gzip");
        this->reply = managerConnection->get(request);
}

void HttpRequest::cancelRequest() {
        if (this->reply) {
            this->reply->abort();
        }
}

void HttpRequest::onRequestFinished(QNetworkReply *reply) {
        if (reply->error() == QNetworkReply::NoError) {
            QByteArray header = reply->rawHeader("Content-Encoding");
            QByteArray bytes;
            if (header == "gzip") {
                bytes = gUncompress(reply->readAll());
            } else {
                bytes = reply->readAll();
            }
            QString data(bytes);
            cout << "onRequestFinished:"<<data.toStdString() << endl;
            emit finished(bytes);
        } else {
            cout << "onRequestFinished reply->error: "<<reply->error()<< endl;
            if (this->isSkipNetWorkError == false) {
                this->handleNetworkError(reply->error());
            }
        }

}

 but only a few first time get data sucess (some maybe slowly, 15 -> 20 seconds to finished) and some get error code = 4 (Time out) later. Url not problem, same with URL on 10.1.

 

And this with my QTcpSocket:

void QWsSocket::connectToHost(const QHostAddress &address, quint16 port, OpenMode mode) {
	handshakeResponse.clear();
	setPeerAddress(address);
	setPeerPort(port);
	setOpenMode(mode);
	tcpSocket->connectToHost(address, port, mode);
}

void ZWebSocket::connectHostWithMultiPort() {
        QHostInfo hostIP = QHostInfo::fromName(QString::fromStdString(Constants::ZINGME_API_CHAT_LIVE_URL));
        if (hostIP.error() == QHostInfo::NoError && !this->_hostPort.isEmpty()) {
            //this->connectToHost(hostIP.addresses().first(), Constants::ZINGME_API_CHAT_LIVE_URL_PORT);
            int port = this->_hostPort.first();
            cout << "try to connect host: " << hostIP.addresses().first().toString().toStdString() << endl;
            cout << "try to connect port: " << port << endl;
            this->connectToHost(hostIP.addresses().first(), port);
        } else {

        }
}

 ZWebSocket extend from QWsSocket, some time connect sucess to server but only first time.

 

Help me point out my mistake ::Surrender: ::Surrender: ::Surrender:::Surrender:::Surrender:::Surrender:

Contributor
anhhungxadieuuit
Posts: 27
Registered: ‎12-18-2012
My Device: Z10, Playbook

Re: Network Error on OS 10.2 build 424

Help :Surrender: :Surrender::Surrender::Surrender::Surrender::Surrender::Surrender::Surrender:

BlackBerry Development Advisor
RSperanza
Posts: 142
Registered: ‎03-08-2012
My Device: Z10

Re: Network Error on OS 10.2 build 424

Hi.

 

Sorry for the delay.   I was out of the office the last couple of days and I reviewed your code (which looks OK at first glance) but I didn't get a chance to test it yet.  Will be doing so today..

BlackBerry Development Advisor
RSperanza
Posts: 142
Registered: ‎03-08-2012
My Device: Z10

Re: Network Error on OS 10.2 build 424

Hi.

 

I tested two of my own sample apps, one uses QTcpSockets and the other uses QNetworkManager, and neither one runs slower on this 10.2 build.

 

Without seeing anything else, I only see two possibilities:

 

1. The IP lookups being performed by QHostInfo every time you connect may be inefficient, especially if you connect to your chat server very often.  I would only perform this lookup at app start and if you cannot connect with any IP addresses.  Cache the results and use the addresses from the cache.

2. You might be running the networking code from a thread that is not a QThread.  This wasn't enforced in earlier releases but is enforced now.

 

Try #1, check #2 and reply back if the changes help.  I will keep watching this thread until the problem is resolved.

Contributor
anhhungxadieuuit
Posts: 27
Registered: ‎12-18-2012
My Device: Z10, Playbook

Re: Network Error on OS 10.2 build 424

Thanks RSperanza,

 

I have found that  QTcpSockets not cause problem here, my chat app connect with server sucess, so we can skip #1.

 

Problem remain with QNetworkAccessManager, I try to send many request with same URL and get fail after 5-6 first time. The failed request begin with error:

 

QEventDispatcherBlackberry: cannot register QSocketNotifier (fd too high) 270
QEventDispatcherBlackberry: cannot register QSocketNotifier (fd too high) 271

 

I'm using QNetworkAccessManager on class HTTPRequest implement from QObject and called from main application Thread to get data with an Singleton of Object:

	Connection* Connection::instance = 0;
	Connection* Connection::getInstance() {
		static QMutex mutex;
		mutex.lock();
		if (instance == 0) {
			instance = new Connection();
		}
		mutex.unlock();
		return instance;
	}
	Connection::Connection():
			HttpRequest() {
	}

void Connection::getInfo() {
        QUrl url = "any URL";
        QObject::connect(this, SIGNAL(finished(QByteArray)), this, SLOT(onRequestComplete(QByteArray)));
        sendRequest(url);
    }

 

Is that problem when I called HttpRequest from Main thread of application which is not a QThread as You said?

 

I'm verry tired now, hope and thanks for your help!

 

BlackBerry Development Advisor
RSperanza
Posts: 142
Registered: ‎03-08-2012
My Device: Z10

Re: Network Error on OS 10.2 build 424

If you call it from main(), yes it can.  QSocketNotifier behaviour is unexpected.

 

I suggest creating a QThread to run that code and start it in your app constructor.   Try that and let me know what happens.