librelist archives

« back to archive

multiple connections to server

multiple connections to server

From:
Sergey Proforov
Date:
2012-11-04 @ 17:34
Hi! Can someone help me please?

I have two NSOperationQueues for working with server mail.gmail.com, each
queue for one account.
All manipulations with server are working inside NSOperationQueue (connect,
fetch...).

But problem is appeared when I trying to fetch messages from each account
simultaneously.
The one of the concurrent fetch operations will fail with a random error (
"protocol error", "stream error", "parse error" etc. ).

If I use one NSOperationQueue for all accounts - there are no errors.


-- 
Best regards,
Sergey Proforov.

Re: [mailcore] multiple connections to server

From:
Jonathan
Date:
2012-11-04 @ 18:55
Hi there.

How many concurrent operations are you trying to perform on your operation
queue? Core folders aren't thread-safe, and will produce random stream 
errors if accessed through different threads simultaneously.

You could try setting the maximum concurrency count to 1 on your operation queue. 

--
Cheers,
Jonathan Willing


On Sunday, November 4, 2012 at 11:34 AM, Sergey Proforov wrote:

> Hi! Can someone help me please? 
> 
> I have two NSOperationQueues for working with server mail.gmail.com 
(http://mail.gmail.com), each queue for one account. 
> All manipulations with server are working inside NSOperationQueue 
(connect, fetch...). 
> 
> But problem is appeared when I trying to fetch messages from each 
account simultaneously. 
> The one of the concurrent fetch operations will fail with a random error
( "protocol error", "stream error", "parse error" etc. ).
> 
> If I use one NSOperationQueue for all accounts - there are no errors.
> 
> 
> -- 
> Best regards, 
> Sergey Proforov.
> 

Re: [mailcore] multiple connections to server

From:
Sergey Proforov
Date:
2012-11-04 @ 19:10
Thanks for reply, Jonathan!
Oh, yes, I forgot to say: I've set maxConcurrentOperationCount = 1;
So all commands to server are sent sequentially ( in bounds of one account
).

May be libetpan in depth shares some data between connections (sessions)?

2012/11/4 Jonathan <jwilling@me.com>

> Hi there.
>
> How many concurrent operations are you trying to perform on your operation
> queue? Core folders aren't thread-safe, and will produce random stream
> errors if accessed through different threads simultaneously.
>
> You could try setting the maximum concurrency count to 1 on your operation
> queue.
>
> --
> Cheers,
> Jonathan Willing
>
> On Sunday, November 4, 2012 at 11:34 AM, Sergey Proforov wrote:
>
> Hi! Can someone help me please?
>
> I have two NSOperationQueues for working with server mail.gmail.com, each
> queue for one account.
> All manipulations with server are working inside NSOperationQueue
> (connect, fetch...).
>
> But problem is appeared when I trying to fetch messages from each account
> simultaneously.
> The one of the concurrent fetch operations will fail with a random error (
> "protocol error", "stream error", "parse error" etc. ).
>
> If I use one NSOperationQueue for all accounts - there are no errors.
>
>
> --
> Best regards,
> Sergey Proforov.
>
>
>


-- 
Best regards,
Serget Proforov.

Re: [mailcore] multiple connections to server

From:
Olivier Pallière
Date:
2012-11-04 @ 19:15
Hi 

But presumably using a connection per account means one connection will 
manage a set of CoreFolders and those won't be shared across threads no?

As long as CoreFolders are created, used and disposed of in the same 
thread, that shouldn't be a problem, no? Or am I missing something?

Many thanks,
Olivier./.

On Nov 4, 2012, at 7:55 PM, Jonathan <jwilling@me.com> wrote:

> Hi there.
> 
> How many concurrent operations are you trying to perform on your 
operation queue? Core folders aren't thread-safe, and will produce random 
stream errors if accessed through different threads simultaneously.
> 
> You could try setting the maximum concurrency count to 1 on your 
operation queue.
> 
> --
> Cheers,
> Jonathan Willing
> 
> On Sunday, November 4, 2012 at 11:34 AM, Sergey Proforov wrote:
> 
>> Hi! Can someone help me please? 
>> 
>> I have two NSOperationQueues for working with server mail.gmail.com, 
each queue for one account. 
>> All manipulations with server are working inside NSOperationQueue 
(connect, fetch...). 
>> 
>> But problem is appeared when I trying to fetch messages from each 
account simultaneously. 
>> The one of the concurrent fetch operations will fail with a random 
error ( "protocol error", "stream error", "parse error" etc. ).
>> 
>> If I use one NSOperationQueue for all accounts - there are no errors.
>> 
>> 
>> -- 
>> Best regards, 
>> Sergey Proforov.
> 

Re: [mailcore] multiple connections to server

From:
Jonathan
Date:
2012-11-04 @ 19:18
Hello.

Actually, core accounts are not thread-safe either. If you want two 
simultaneous threads for the same account, a new core account connection 
is needed.  

--
Cheers,
Jonathan Willing


On Sunday, November 4, 2012 at 1:15 PM, Olivier Pallière wrote:

> Hi  
>  
> But presumably using a connection per account means one connection will 
manage a set of CoreFolders and those won't be shared across threads no?
>  
> As long as CoreFolders are created, used and disposed of in the same 
thread, that shouldn't be a problem, no? Or am I missing something?
>  
> Many thanks,
> Olivier./.
>  
> On Nov 4, 2012, at 7:55 PM, Jonathan <jwilling@me.com 
(mailto:jwilling@me.com)> wrote:
>  
> > Hi there.
> >  
> > How many concurrent operations are you trying to perform on your 
operation queue? Core folders aren't thread-safe, and will produce random 
stream errors if accessed through different threads simultaneously.
> >  
> > You could try setting the maximum concurrency count to 1 on your 
operation queue.  
> >  
> > --
> > Cheers,
> > Jonathan Willing
> >  
> >  
> > On Sunday, November 4, 2012 at 11:34 AM, Sergey Proforov wrote:
> >  
> > > Hi! Can someone help me please?  
> > >  
> > > I have two NSOperationQueues for working with server mail.gmail.com 
(http://mail.gmail.com), each queue for one account.  
> > > All manipulations with server are working inside NSOperationQueue 
(connect, fetch...).  
> > >  
> > > But problem is appeared when I trying to fetch messages from each 
account simultaneously.  
> > > The one of the concurrent fetch operations will fail with a random 
error ( "protocol error", "stream error", "parse error" etc. ).
> > >  
> > > If I use one NSOperationQueue for all accounts - there are no errors.
> > >  
> > >  
> > > --  
> > > Best regards,  
> > > Sergey Proforov.
> > >  
> >  

Re: [mailcore] multiple connections to server

From:
Olivier Pallière
Date:
2012-11-04 @ 19:32
Hi Jonathan,

Thanks for your feedback. Yes I understood that and meant one connection 
as one operation queue. 

If one operation queue spawns one account, and does all its work within 
its one thread, then it's all good right?

Olivier./.

On Nov 4, 2012, at 8:18 PM, Jonathan <jwilling@me.com> wrote:

> Hello.
> 
> Actually, core accounts are not thread-safe either. If you want two 
simultaneous threads for the same account, a new core account connection 
is needed.
> 
> --
> Cheers,
> Jonathan Willing
> 
> On Sunday, November 4, 2012 at 1:15 PM, Olivier Pallière wrote:
> 
>> Hi 
>> 
>> But presumably using a connection per account means one connection will
manage a set of CoreFolders and those won't be shared across threads no?
>> 
>> As long as CoreFolders are created, used and disposed of in the same 
thread, that shouldn't be a problem, no? Or am I missing something?
>> 
>> Many thanks,
>> Olivier./.
>> 
>> On Nov 4, 2012, at 7:55 PM, Jonathan <jwilling@me.com> wrote:
>> 
>>> Hi there.
>>> 
>>> How many concurrent operations are you trying to perform on your 
operation queue? Core folders aren't thread-safe, and will produce random 
stream errors if accessed through different threads simultaneously.
>>> 
>>> You could try setting the maximum concurrency count to 1 on your 
operation queue.
>>> 
>>> --
>>> Cheers,
>>> Jonathan Willing
>>> 
>>> On Sunday, November 4, 2012 at 11:34 AM, Sergey Proforov wrote:
>>> 
>>>> Hi! Can someone help me please? 
>>>> 
>>>> I have two NSOperationQueues for working with server mail.gmail.com, 
each queue for one account. 
>>>> All manipulations with server are working inside NSOperationQueue 
(connect, fetch...). 
>>>> 
>>>> But problem is appeared when I trying to fetch messages from each 
account simultaneously. 
>>>> The one of the concurrent fetch operations will fail with a random 
error ( "protocol error", "stream error", "parse error" etc. ).
>>>> 
>>>> If I use one NSOperationQueue for all accounts - there are no errors.
>>>> 
>>>> 
>>>> -- 
>>>> Best regards, 
>>>> Sergey Proforov.
> 

Re: [mailcore] multiple connections to server

From:
Jonathan
Date:
2012-11-04 @ 19:33
Yes, as long as all the connection, fetching, and other work happens 
within one single thread you should be good to go!

Just in case, it might be good to hear from Matt to make sure I'm correct.  

--
Cheers,
Jonathan Willing


On Sunday, November 4, 2012 at 1:32 PM, Olivier Pallière wrote:

> Hi Jonathan,
>  
> Thanks for your feedback. Yes I understood that and meant one connection
as one operation queue.  
>  
> If one operation queue spawns one account, and does all its work within 
its one thread, then it's all good right?
>  
> Olivier./.
>  
> On Nov 4, 2012, at 8:18 PM, Jonathan <jwilling@me.com 
(mailto:jwilling@me.com)> wrote:
>  
> > Hello.
> >  
> > Actually, core accounts are not thread-safe either. If you want two 
simultaneous threads for the same account, a new core account connection 
is needed.  
> >  
> > --
> > Cheers,
> > Jonathan Willing
> >  
> >  
> > On Sunday, November 4, 2012 at 1:15 PM, Olivier Pallière wrote:
> >  
> > > Hi  
> > >  
> > > But presumably using a connection per account means one connection 
will manage a set of CoreFolders and those won't be shared across threads 
no?
> > >  
> > > As long as CoreFolders are created, used and disposed of in the same
thread, that shouldn't be a problem, no? Or am I missing something?
> > >  
> > > Many thanks,
> > > Olivier./.
> > >  
> > > On Nov 4, 2012, at 7:55 PM, Jonathan <jwilling@me.com 
(mailto:jwilling@me.com)> wrote:
> > >  
> > > > Hi there.
> > > >  
> > > > How many concurrent operations are you trying to perform on your 
operation queue? Core folders aren't thread-safe, and will produce random 
stream errors if accessed through different threads simultaneously.
> > > >  
> > > > You could try setting the maximum concurrency count to 1 on your 
operation queue.  
> > > >  
> > > > --
> > > > Cheers,
> > > > Jonathan Willing
> > > >  
> > > >  
> > > > On Sunday, November 4, 2012 at 11:34 AM, Sergey Proforov wrote:
> > > >  
> > > > > Hi! Can someone help me please?  
> > > > >  
> > > > > I have two NSOperationQueues for working with server 
mail.gmail.com (http://mail.gmail.com), each queue for one account.  
> > > > > All manipulations with server are working inside 
NSOperationQueue (connect, fetch...).  
> > > > >  
> > > > > But problem is appeared when I trying to fetch messages from 
each account simultaneously.  
> > > > > The one of the concurrent fetch operations will fail with a 
random error ( "protocol error", "stream error", "parse error" etc. ).
> > > > >  
> > > > > If I use one NSOperationQueue for all accounts - there are no errors.
> > > > >  
> > > > >  
> > > > > --  
> > > > > Best regards,  
> > > > > Sergey Proforov.
> > > > >  
> > > >  
> >  

Re: [mailcore] multiple connections to server

From:
Matt Ronge
Date:
2012-11-05 @ 21:01
Jonathan is correct. As long as each thread has its own instance of a 
CTCoreAccount, and CTCoreFolder everything should be fine. Just make sure 
you aren't sharing any of those objects across threads!

I do that in a few of my apps that use MailCore as well
--
Matt Ronge

iOS Developer & Consultant
Central Atomics Inc.
http://www.centralatomics.com






On Nov 4, 2012, at 1:33 PM, Jonathan <jwilling@me.com> wrote:

> Yes, as long as all the connection, fetching, and other work happens 
within one single thread you should be good to go!
> 
> Just in case, it might be good to hear from Matt to make sure I'm correct.
> 
> --
> Cheers,
> Jonathan Willing
> 
> On Sunday, November 4, 2012 at 1:32 PM, Olivier Pallière wrote:
> 
>> Hi Jonathan,
>> 
>> Thanks for your feedback. Yes I understood that and meant one 
connection as one operation queue. 
>> 
>> If one operation queue spawns one account, and does all its work within
its one thread, then it's all good right?
>> 
>> Olivier./.
>> 
>> On Nov 4, 2012, at 8:18 PM, Jonathan <jwilling@me.com> wrote:
>> 
>>> Hello.
>>> 
>>> Actually, core accounts are not thread-safe either. If you want two 
simultaneous threads for the same account, a new core account connection 
is needed.
>>> 
>>> --
>>> Cheers,
>>> Jonathan Willing
>>> 
>>> On Sunday, November 4, 2012 at 1:15 PM, Olivier Pallière wrote:
>>> 
>>>> Hi 
>>>> 
>>>> But presumably using a connection per account means one connection 
will manage a set of CoreFolders and those won't be shared across threads 
no?
>>>> 
>>>> As long as CoreFolders are created, used and disposed of in the same 
thread, that shouldn't be a problem, no? Or am I missing something?
>>>> 
>>>> Many thanks,
>>>> Olivier./.
>>>> 
>>>> On Nov 4, 2012, at 7:55 PM, Jonathan <jwilling@me.com> wrote:
>>>> 
>>>>> Hi there.
>>>>> 
>>>>> How many concurrent operations are you trying to perform on your 
operation queue? Core folders aren't thread-safe, and will produce random 
stream errors if accessed through different threads simultaneously.
>>>>> 
>>>>> You could try setting the maximum concurrency count to 1 on your 
operation queue.
>>>>> 
>>>>> --
>>>>> Cheers,
>>>>> Jonathan Willing
>>>>> 
>>>>> On Sunday, November 4, 2012 at 11:34 AM, Sergey Proforov wrote:
>>>>> 
>>>>>> Hi! Can someone help me please? 
>>>>>> 
>>>>>> I have two NSOperationQueues for working with server 
mail.gmail.com, each queue for one account. 
>>>>>> All manipulations with server are working inside NSOperationQueue 
(connect, fetch...). 
>>>>>> 
>>>>>> But problem is appeared when I trying to fetch messages from each 
account simultaneously. 
>>>>>> The one of the concurrent fetch operations will fail with a random 
error ( "protocol error", "stream error", "parse error" etc. ).
>>>>>> 
>>>>>> If I use one NSOperationQueue for all accounts - there are no errors.
>>>>>> 
>>>>>> 
>>>>>> -- 
>>>>>> Best regards, 
>>>>>> Sergey Proforov.
>>>>>> 
>>>>> 
>>> 
> 

Re: [mailcore] multiple connections to server

From:
Olivier Pallière
Date:
2012-11-05 @ 21:29
Hi Matt,

I'm sorry to digress but I have a question relating to that. 

Is it ok, or advisable, from an imap client point of view, to have one 
thread per folder, and so one connection to the imap server per folder, or
should we use one thread per account and process all folders in this one 
thread?

Many thanks,
Olivier./.

On Nov 5, 2012, at 10:01 PM, Matt Ronge <mronge@mronge.com> wrote:

> Jonathan is correct. As long as each thread has its own instance of a 
CTCoreAccount, and CTCoreFolder everything should be fine. Just make sure 
you aren't sharing any of those objects across threads!
> 
> I do that in a few of my apps that use MailCore as well
> --
> Matt Ronge
> 
> iOS Developer & Consultant
> Central Atomics Inc.
> http://www.centralatomics.com
> 
> 
> 
> 
> 
> 
> On Nov 4, 2012, at 1:33 PM, Jonathan <jwilling@me.com> wrote:
> 
>> Yes, as long as all the connection, fetching, and other work happens 
within one single thread you should be good to go!
>> 
>> Just in case, it might be good to hear from Matt to make sure I'm correct.
>> 
>> --
>> Cheers,
>> Jonathan Willing
>> 
>> On Sunday, November 4, 2012 at 1:32 PM, Olivier Pallière wrote:
>> 
>>> Hi Jonathan,
>>> 
>>> Thanks for your feedback. Yes I understood that and meant one 
connection as one operation queue. 
>>> 
>>> If one operation queue spawns one account, and does all its work 
within its one thread, then it's all good right?
>>> 
>>> Olivier./.
>>> 
>>> On Nov 4, 2012, at 8:18 PM, Jonathan <jwilling@me.com> wrote:
>>> 
>>>> Hello.
>>>> 
>>>> Actually, core accounts are not thread-safe either. If you want two 
simultaneous threads for the same account, a new core account connection 
is needed.
>>>> 
>>>> --
>>>> Cheers,
>>>> Jonathan Willing
>>>> 
>>>> On Sunday, November 4, 2012 at 1:15 PM, Olivier Pallière wrote:
>>>> 
>>>>> Hi 
>>>>> 
>>>>> But presumably using a connection per account means one connection 
will manage a set of CoreFolders and those won't be shared across threads 
no?
>>>>> 
>>>>> As long as CoreFolders are created, used and disposed of in the same
thread, that shouldn't be a problem, no? Or am I missing something?
>>>>> 
>>>>> Many thanks,
>>>>> Olivier./.
>>>>> 
>>>>> On Nov 4, 2012, at 7:55 PM, Jonathan <jwilling@me.com> wrote:
>>>>> 
>>>>>> Hi there.
>>>>>> 
>>>>>> How many concurrent operations are you trying to perform on your 
operation queue? Core folders aren't thread-safe, and will produce random 
stream errors if accessed through different threads simultaneously.
>>>>>> 
>>>>>> You could try setting the maximum concurrency count to 1 on your 
operation queue.
>>>>>> 
>>>>>> --
>>>>>> Cheers,
>>>>>> Jonathan Willing
>>>>>> 
>>>>>> On Sunday, November 4, 2012 at 11:34 AM, Sergey Proforov wrote:
>>>>>> 
>>>>>>> Hi! Can someone help me please? 
>>>>>>> 
>>>>>>> I have two NSOperationQueues for working with server 
mail.gmail.com, each queue for one account. 
>>>>>>> All manipulations with server are working inside NSOperationQueue 
(connect, fetch...). 
>>>>>>> 
>>>>>>> But problem is appeared when I trying to fetch messages from each 
account simultaneously. 
>>>>>>> The one of the concurrent fetch operations will fail with a random
error ( "protocol error", "stream error", "parse error" etc. ).
>>>>>>> 
>>>>>>> If I use one NSOperationQueue for all accounts - there are no errors.
>>>>>>> 
>>>>>>> 
>>>>>>> -- 
>>>>>>> Best regards, 
>>>>>>> Sergey Proforov.
> 

Re: [mailcore] multiple connections to server

From:
Matt Ronge
Date:
2012-11-06 @ 19:14
In the work I've done, I usually have two connections per account. I use 
one to download the message lists and another that downloads individual 
message bodies on demand.

Most IMAP servers have a connection limit, and one ancient server has a 
connection limit of 1, but I don't really worry about that server. In my 
experience I've found 2 per account is OK, but you wouldn't want to go 
alot higher than that.
--
Matt Ronge

iOS Developer & Consultant
Central Atomics Inc.
http://www.centralatomics.com






On Nov 5, 2012, at 3:29 PM, Olivier Pallière <olivier@molowa.com> wrote:

> Hi Matt,
> 
> I'm sorry to digress but I have a question relating to that. 
> 
> Is it ok, or advisable, from an imap client point of view, to have one 
thread per folder, and so one connection to the imap server per folder, or
should we use one thread per account and process all folders in this one 
thread?
> 
> Many thanks,
> Olivier./.
> 
> On Nov 5, 2012, at 10:01 PM, Matt Ronge <mronge@mronge.com> wrote:
> 
>> Jonathan is correct. As long as each thread has its own instance of a 
CTCoreAccount, and CTCoreFolder everything should be fine. Just make sure 
you aren't sharing any of those objects across threads!
>> 
>> I do that in a few of my apps that use MailCore as well
>> --
>> Matt Ronge
>> 
>> iOS Developer & Consultant
>> Central Atomics Inc.
>> http://www.centralatomics.com
>> 
>> 
>> 
>> 
>> 
>> 
>> On Nov 4, 2012, at 1:33 PM, Jonathan <jwilling@me.com> wrote:
>> 
>>> Yes, as long as all the connection, fetching, and other work happens 
within one single thread you should be good to go!
>>> 
>>> Just in case, it might be good to hear from Matt to make sure I'm correct.
>>> 
>>> --
>>> Cheers,
>>> Jonathan Willing
>>> 
>>> On Sunday, November 4, 2012 at 1:32 PM, Olivier Pallière wrote:
>>> 
>>>> Hi Jonathan,
>>>> 
>>>> Thanks for your feedback. Yes I understood that and meant one 
connection as one operation queue. 
>>>> 
>>>> If one operation queue spawns one account, and does all its work 
within its one thread, then it's all good right?
>>>> 
>>>> Olivier./.
>>>> 
>>>> On Nov 4, 2012, at 8:18 PM, Jonathan <jwilling@me.com> wrote:
>>>> 
>>>>> Hello.
>>>>> 
>>>>> Actually, core accounts are not thread-safe either. If you want two 
simultaneous threads for the same account, a new core account connection 
is needed.
>>>>> 
>>>>> --
>>>>> Cheers,
>>>>> Jonathan Willing
>>>>> 
>>>>> On Sunday, November 4, 2012 at 1:15 PM, Olivier Pallière wrote:
>>>>> 
>>>>>> Hi 
>>>>>> 
>>>>>> But presumably using a connection per account means one connection 
will manage a set of CoreFolders and those won't be shared across threads 
no?
>>>>>> 
>>>>>> As long as CoreFolders are created, used and disposed of in the 
same thread, that shouldn't be a problem, no? Or am I missing something?
>>>>>> 
>>>>>> Many thanks,
>>>>>> Olivier./.
>>>>>> 
>>>>>> On Nov 4, 2012, at 7:55 PM, Jonathan <jwilling@me.com> wrote:
>>>>>> 
>>>>>>> Hi there.
>>>>>>> 
>>>>>>> How many concurrent operations are you trying to perform on your 
operation queue? Core folders aren't thread-safe, and will produce random 
stream errors if accessed through different threads simultaneously.
>>>>>>> 
>>>>>>> You could try setting the maximum concurrency count to 1 on your 
operation queue.
>>>>>>> 
>>>>>>> --
>>>>>>> Cheers,
>>>>>>> Jonathan Willing
>>>>>>> 
>>>>>>> On Sunday, November 4, 2012 at 11:34 AM, Sergey Proforov wrote:
>>>>>>> 
>>>>>>>> Hi! Can someone help me please? 
>>>>>>>> 
>>>>>>>> I have two NSOperationQueues for working with server 
mail.gmail.com, each queue for one account. 
>>>>>>>> All manipulations with server are working inside NSOperationQueue
(connect, fetch...). 
>>>>>>>> 
>>>>>>>> But problem is appeared when I trying to fetch messages from each
account simultaneously. 
>>>>>>>> The one of the concurrent fetch operations will fail with a 
random error ( "protocol error", "stream error", "parse error" etc. ).
>>>>>>>> 
>>>>>>>> If I use one NSOperationQueue for all accounts - there are no errors.
>>>>>>>> 
>>>>>>>> 
>>>>>>>> -- 
>>>>>>>> Best regards, 
>>>>>>>> Sergey Proforov.
>> 

Re: [mailcore] multiple connections to server

From:
Sergey Proforov
Date:
2012-11-06 @ 19:56
Great thanks, guys! It works now, it was my mistake.
I've made the conclusion that i need a second connection for fetching a
message body and Matt confirmed my thoughts. Thanks Matt!

I have one more question:
How can i move or copy a bulk of UIDs, CTCoreFolder has method only for
copying only one message at once. And if I copy messages with
NSOperationQueue one by one - it takes too long time, about 1 message in
second.

2012/11/6 Matt Ronge <mronge@mronge.com>

> In the work I've done, I usually have two connections per account. I use
> one to download the message lists and another that downloads individual
> message bodies on demand.
>
> Most IMAP servers have a connection limit, and one ancient server has a
> connection limit of 1, but I don't really worry about that server. In my
> experience I've found 2 per account is OK, but you wouldn't want to go alot
> higher than that.
> --
> Matt Ronge
>
> iOS Developer & Consultant
> Central Atomics Inc.
> http://www.centralatomics.com
>
>
>
>
>
>
> On Nov 5, 2012, at 3:29 PM, Olivier Pallière <olivier@molowa.com> wrote:
>
> > Hi Matt,
> >
> > I'm sorry to digress but I have a question relating to that.
> >
> > Is it ok, or advisable, from an imap client point of view, to have one
> thread per folder, and so one connection to the imap server per folder, or
> should we use one thread per account and process all folders in this one
> thread?
> >
> > Many thanks,
> > Olivier./.
> >
> > On Nov 5, 2012, at 10:01 PM, Matt Ronge <mronge@mronge.com> wrote:
> >
> >> Jonathan is correct. As long as each thread has its own instance of a
> CTCoreAccount, and CTCoreFolder everything should be fine. Just make sure
> you aren't sharing any of those objects across threads!
> >>
> >> I do that in a few of my apps that use MailCore as well
> >> --
> >> Matt Ronge
> >>
> >> iOS Developer & Consultant
> >> Central Atomics Inc.
> >> http://www.centralatomics.com
> >>
> >>
> >>
> >>
> >>
> >>
> >> On Nov 4, 2012, at 1:33 PM, Jonathan <jwilling@me.com> wrote:
> >>
> >>> Yes, as long as all the connection, fetching, and other work happens
> within one single thread you should be good to go!
> >>>
> >>> Just in case, it might be good to hear from Matt to make sure I'm
> correct.
> >>>
> >>> --
> >>> Cheers,
> >>> Jonathan Willing
> >>>
> >>> On Sunday, November 4, 2012 at 1:32 PM, Olivier Pallière wrote:
> >>>
> >>>> Hi Jonathan,
> >>>>
> >>>> Thanks for your feedback. Yes I understood that and meant one
> connection as one operation queue.
> >>>>
> >>>> If one operation queue spawns one account, and does all its work
> within its one thread, then it's all good right?
> >>>>
> >>>> Olivier./.
> >>>>
> >>>> On Nov 4, 2012, at 8:18 PM, Jonathan <jwilling@me.com> wrote:
> >>>>
> >>>>> Hello.
> >>>>>
> >>>>> Actually, core accounts are not thread-safe either. If you want two
> simultaneous threads for the same account, a new core account connection is
> needed.
> >>>>>
> >>>>> --
> >>>>> Cheers,
> >>>>> Jonathan Willing
> >>>>>
> >>>>> On Sunday, November 4, 2012 at 1:15 PM, Olivier Pallière wrote:
> >>>>>
> >>>>>> Hi
> >>>>>>
> >>>>>> But presumably using a connection per account means one connection
> will manage a set of CoreFolders and those won't be shared across threads
> no?
> >>>>>>
> >>>>>> As long as CoreFolders are created, used and disposed of in the
> same thread, that shouldn't be a problem, no? Or am I missing something?
> >>>>>>
> >>>>>> Many thanks,
> >>>>>> Olivier./.
> >>>>>>
> >>>>>> On Nov 4, 2012, at 7:55 PM, Jonathan <jwilling@me.com> wrote:
> >>>>>>
> >>>>>>> Hi there.
> >>>>>>>
> >>>>>>> How many concurrent operations are you trying to perform on your
> operation queue? Core folders aren't thread-safe, and will produce random
> stream errors if accessed through different threads simultaneously.
> >>>>>>>
> >>>>>>> You could try setting the maximum concurrency count to 1 on your
> operation queue.
> >>>>>>>
> >>>>>>> --
> >>>>>>> Cheers,
> >>>>>>> Jonathan Willing
> >>>>>>>
> >>>>>>> On Sunday, November 4, 2012 at 11:34 AM, Sergey Proforov wrote:
> >>>>>>>
> >>>>>>>> Hi! Can someone help me please?
> >>>>>>>>
> >>>>>>>> I have two NSOperationQueues for working with server
> mail.gmail.com, each queue for one account.
> >>>>>>>> All manipulations with server are working inside NSOperationQueue
> (connect, fetch...).
> >>>>>>>>
> >>>>>>>> But problem is appeared when I trying to fetch messages from each
> account simultaneously.
> >>>>>>>> The one of the concurrent fetch operations will fail with a
> random error ( "protocol error", "stream error", "parse error" etc. ).
> >>>>>>>>
> >>>>>>>> If I use one NSOperationQueue for all accounts - there are no
> errors.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> --
> >>>>>>>> Best regards,
> >>>>>>>> Sergey Proforov.
> >>
>
>


-- 
Best regards,
Sergey Proforov.

Re: [mailcore] multiple connections to server

From:
Matt Ronge
Date:
2012-11-20 @ 18:58
On Nov 6, 2012, at 1:56 PM, Sergey Proforov <proforov@gmail.com> wrote:

> I have one more question: 
> How can i move or copy a bulk of UIDs, CTCoreFolder has method only for 
copying only one message at once. And if I copy messages with 
NSOperationQueue one by one - it takes too long time, about 1 message in 
second. 

You'll have to drop down to a lower level and use the LibEtPan C functions
directly to get bulk copy working. Check out mailimap.h and 
mailimap_uid_copy()

One thing I do currently that seems to work pretty well is use one 
NSOperation for the bulk copy. Inside the NSOperation I do individual 
copies in a for loop.
--
Matt Ronge

iOS Developer & Consultant
Central Atomics Inc.
http://www.centralatomics.com