MailCore / mailcore2

MailCore 2 provide a simple and asynchronous API to work with e-mail protocols IMAP, POP and SMTP. The API has been redesigned from ground up.
Other
2.6k stars 624 forks source link

MailCore2 ios: Unable to parse response from server. #433

Closed Pankaj03 closed 10 years ago

Pankaj03 commented 10 years ago

Hello

i am getting error : "Unable to parse response from server."

But when i remove following file: scripts/prebuilt.lists

it is working fine.

Everytime i have to remove this file and buil again?

Please do help.

Pankaj03 commented 10 years ago

Yes.

Thanks for your kind support.

Pankaj03 commented 10 years ago

@dinhviethoa @CodaFi Hello! Now please help me, what is wrong with this following response from server as i am again getting "Unable to parse response from server" error:

4033 FETCH (UID 32569448 FLAGS (\SEEN) INTERNALDATE "27-Dec-2013 11:22:31 +0000" RFC822.SIZE   44704 ENVELOPE ("Fri, 27 Dec 2013 11:21:45 +0000" "RE: Fw : Fw : Fw : Online Bill Collection integration document  and" (("Naval Kishore Sharma - HCLI" NIL "navalsharma" "hcl.com")) (("Naval Kishore Sharma - HCLI" NIL "navalsharma" "hcl.com")) (("Naval Kishore Sharma - HCLI" NIL "navalsharma" "hcl.com")) (("Kapil Sharma" NIL "kapil" "datainfocom.in")(NIL NIL ""praveen.s" "nxgn.in"")) (("srao@dil.in" NIL "srao" "dil.in")("Atul Kumar - HCLI" NIL "atul.dahiya" "hcl.com")) NIL "" "<2B7D5C7F2C24DD4CB4864D1A454D137614C7688A@NDA-ASST-MBS04.ASSOCIATES.CORP.HCL.IN>") BODY[HEADER.FIELDS (Date Subject From Sender Reply-To To Cc Message-ID References In-Reply-To)] {801}

Now i didn't pass any BODYSTRUCTURE command. Please do help me.

Thanks!

denniscyoung commented 10 years ago

Hi, I also run into this problem "Unable to parse response from server.", the app crashed; it happened in the middle of downloading a mail box with a lot of mails. I try to get the plainTextBodyRendering for each email and display a summary or list view. If I replace the fetchMessagesByUIDOperationWithFolder (with MCOIMAPMessagesRequestKindStructure flag set) with fetchMessageByUIDOperationWithFolder, the download becomes very slow. Is there a way to just skip that offending email, or a way to handle the error gracefully, or other work around? Thanks.

Pankaj03 commented 10 years ago

Can you share some error logs? Try to fetch the message without passing BODYSTRUCTURE as requestkind.

denniscyoung commented 10 years ago

It works fine if i don't set BODYSTRUCTURE as requestkind in the fetchMessagesByUIDOperationWithFolder. The problem is that the work around of using fetchMessageByUIDOperationWithFolder becomes very slow as i am downloading a lot of mails and want to show plainTextBodyRendering in the summary view.

Pankaj03 commented 10 years ago

Instead of setting BODYSTRUCTURE, fetch full content of message using MCOIMAPFetchContentOperation. For performance issue, get the message headers first and call asynchronous for full content.

denniscyoung commented 10 years ago

Hi Pankaj03, thanks for the suggestion, i tried that, in my situation fetching the full content is too slow. I don't mind skipping the offending mail, is there a way to do that or some other error handling?

Pankaj03 commented 10 years ago

Can you show some error logs?

denniscyoung commented 10 years ago
* 2755 FETCH (FLAGS (\Answered \Seen) UID 2823 INTERNALDATE "13-Mar-2007 03:27:04 +0000" BODYSTRUCTURE ((("text" "plain" ("charset" "iso-8859-1" "format" "flowed") NIL NIL "quoted-printable" 1168 61 NIL ("inline" NIL) NIL NIL)("text" "html" ("charset" "iso-8859-1") NIL NIL "quoted-printable" 2946 61 NIL ("inline" NIL) NIL NIL) "alternative" ("boundary" "----=_Part_12639_7265348.1173756422344") NIL)("text" "html" ("name" "394930N?.htm" "charset" "ansi_x3.4-1968") NIL NIL "base64" 31528 404 NIL ("attachment" ("filename" "=?ISO-2022-JP?B?Mzk0OTMwGyRCTXtWWxsoQi5odG0=?=")) NIL NIL)("text" "html" ("name" "2160064??* 

* Internal error writing data
Pankaj03 commented 10 years ago

I need complete error log, means whole response.

denniscyoung commented 10 years ago

I already turned on MCLogEnabled = 1 in MCLog.c. Is there another flag that shows the whole response? This is happening inside the MCOIMAPFetchMessagesOperation for fetchMessagesByUIDOperationWithFolder, with requestKind = (MCOIMAPMessagesRequestKindHeaders | MCOIMAPMessagesRequestKindStructure | MCOIMAPMessagesRequestKindInternalDate | MCOIMAPMessagesRequestKindHeaderSubject | MCOIMAPMessagesRequestKindFlags);

Pankaj03 commented 10 years ago

Try by adding following code:

[self.imapSession setConnectionLogger:^(void * connectionID, MCOConnectionLogType type, NSData * data) { NSString *setConnectionLoggerStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"ConnectionLogger event logged: %i withData: %@", type, setConnectionLoggerStr); }];

and provide the console log.

denniscyoung commented 10 years ago

i added the code setConnectionLogger, but i don't see much difference or new data, here's the log:

* 2755 FETCH (FLAGS (\Answered \Seen) UID 2823 INTERNALDATE "13-Mar-2007 03:27:04 +0000" BODYSTRUCTURE ((("text" "plain" ("charset" "iso-8859-1" "format" "flowed") NIL NIL "quoted-printable" 1168 61 NIL ("inline" NIL) NIL NIL)("text" "html" ("charset" "iso-8859-1") NIL NIL "quoted-printable" 2946 61 NIL ("inline" NIL) NIL NIL) "alternative" ("boundary" "----=_Part_12639_7265348.1173756422344") NIL)("text" "html" ("name" "394930N?.htm" "charset" "ansi_x3.4-1968") NIL NIL "base64" 31528 404 NIL ("attachment" ("filename" "=?ISO-2022-JP?B?Mzk0OTMwGyRCTXtWWxsoQi5odG0=?=")) NIL NIL)("text" "html" ("name" "2160064??* 

* Internal error writing data

2014-02-12 23:25:38.994 [6630:910f] MCIMAPPart.cc:135: attachment 1.1
2014-02-12 23:25:38.995 [6630:910f] MCIMAPPart.cc:135: attachment 1.2
2014-02-12 23:25:38.998 [6630:910f] MCIMAPSession.cc:1888: parse envelope 2817
2014-02-12 23:25:39.006 [6630:910f] MCIMAPPart.cc:135: attachment 1.1
2014-02-12 23:25:39.007 [6630:910f] MCIMAPPart.cc:135: attachment 1.2
2014-02-12 23:25:39.007 [6630:910f] MCIMAPSession.cc:1888: parse envelope 2818
2014-02-12 23:25:39.011 [6630:910f] MCIMAPPart.cc:135: attachment 1.1
2014-02-12 23:25:39.012 [6630:910f] MCIMAPPart.cc:135: attachment 1.2
2014-02-12 23:25:39.015 [6630:910f] MCIMAPSession.cc:1888: parse envelope 2819
2014-02-12 23:25:39.021 [6630:910f] MCIMAPPart.cc:135: attachment 1.1
2014-02-12 23:25:39.023 [6630:910f] MCIMAPPart.cc:135: attachment 1.2
2014-02-12 23:25:39.024 [6630:910f] MCIMAPSession.cc:1888: parse envelope 2820
2014-02-12 23:25:39.028 [6630:910f] MCIMAPPart.cc:135: attachment 1.1
2014-02-12 23:25:39.029 [6630:910f] MCIMAPPart.cc:135: attachment 1.2
2014-02-12 23:25:39.029 [6630:910f] MCIMAPSession.cc:1888: parse envelope 2821
2014-02-12 23:26:09.035 ForkM[6630:910f] ConnectionLogger event logged: 4 withData: 
2014-02-12 23:26:39.038 ForkM[6630:910f] ConnectionLogger event logged: 4 withData: 
2014-02-12 23:27:09.041 ForkM[6630:910f] ConnectionLogger event logged: 4 withData: 
2014-02-12 23:27:39.044 ForkM[6630:910f] ConnectionLogger event logged: 4 withData: 
2014-02-12 23:28:09.047 ForkM[6630:910f] ConnectionLogger event logged: 4 withData: 
2014-02-12 23:28:39.050 ForkM[6630:910f] ConnectionLogger event logged: 4 withData: 
2014-02-12 23:29:09.053 ForkM[6630:910f] ConnectionLogger event logged: 4 withData: 
2014-02-12 23:29:09.054 ForkM[6630:910f] ConnectionLogger event logged: 3 withData: 2755 FETCH (FLAGS (\Answered \Seen) UID 2823 INTERNALDATE "13-Mar-2007 03:27:04 +0000" BODYSTRUCTURE ((("text" "plain" ("charset" "iso-8859-1" "format" "flowed") NIL NIL "quoted-printable" 1168 61 NIL ("inline" NIL) NIL NIL)("text" "html" ("charset" "iso-8859-1") NIL NIL "quoted-printable" 2946 61 NIL ("inline" NIL) NIL NIL) "alternative" ("boundary" "----=_Part_12639_7265348.1173756422344") NIL)("text" "html" ("name" "394930N?.htm" "charset" "ansi_x3.4-1968") NIL NIL "base64" 31528 404 NIL ("attachment" ("filename" "=?ISO-2022-JP?B?Mzk0OTMwGyRCTXtWWxsoQi5odG0=?=")) NIL NIL)("text" "html" ("name" "2160064??* 

* Internal error writing data

2014-02-12 23:29:09.056 [6630:910f] MCIMAPSession.cc:2274: error parse
2014-02-12 23:29:09.057 ForkM[6630:60b] Oh crap, fetchMessagesByUIDOperationWithFolder error Error Domain=MCOErrorDomain Code=3 "Unable to parse response from server." UserInfo=0x15dcbe90 {NSLocalizedDescription=Unable to parse response from server.}
dinhvh commented 10 years ago

It looks like your server is failing:

* Internal error writing data
dinhvh commented 10 years ago

Which server is it?

denniscyoung commented 10 years ago

Yahoo (imap.mail.yahoo.com). When this happens, is there a graceful way to handle it such that i can get whatever has been downloaded, or just skip it?