문제

I'm using long-polling technique with ksoap like this:

HttpTransportSE getMessagesTransport = new HttpTransportSE(URL, 60000);
getMessagesTransport.call(SOAP_ACTION, envelope);

It is working fine if I only have one invocation of the Web Service at the same time. , but if I invoke another Web Service while the other is requested, it is not called until the other ends.

It seems port 80 is blocked in Android client and only is allowed one request to domain:port (domain:80)

Is there any way to increase that number of connections?

(I preafear don't use Comet arquitechture or Asyn WebServices).

Thank you!!

도움이 되었습니까?

해결책 2

I've created a generic class to forget in wich version we are. When we create an AsyncTask we always extends of AsyncTaskThreadPool. Hope it helps you!

public abstract class AsyncTaskThreadPool<T1, T2, T3> extends AsyncTask<T1, T2, T3> {

    public void ExecuteThreadPool(T1 param)
    {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            this.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, param);
        } else {
            this.execute(param);
        }
    }

    protected abstract T3 doInBackground(T1... params);


}

다른 팁

The problem was that I was invoking 2 async tasks and if version of android >= HONEYCOMB you have to execute your async tasks in the threadpool because one locks to other:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        new SendMessageToEventAsync(this, formattedMessageToSend)
                .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "");
    } else {
        new SendMessageToEventAsync(this, formattedMessageToSend)
                .execute("");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top