SOAP fails in iOS when using SSL ("IOHandler value is not valid.")

I have a simple SOAP client, which works fine on Windows and OSX.  On the iOS Simulator and the device I get the exception "IOHandler value is not valid." when using SSL.  It works fine non-SSL.

The problem appears to be caused by line 1267 in Soap.SOAPHTTPTrans.pas:

      IndyHttp.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);

When running on iOS, the IndyHttp.IOHandler is nil after this line of code has been run.  This appears to be due to the fact that in IdTCPConnection.pas we have the line:

{$IFDEF USE_OBJECT_ARC}[Weak]{$ENDIF} FIOHandler: TIdIOHandler;

If I include IdTCPConnection.pas in my project and remove the [Weak] annotation it works fine.  So it must be that the object goes out of scope because of the weak reference.

So, making the above change fixes my problem, but presumably the [Weak] annotation is there for a reason.  The question is then: will my application now leak?
0
David
7/4/2013 9:51:49 AM
embarcadero.delphi.firemonkey 4901 articles. 4 followers. Follow

5 Replies
863 Views

Similar Articles

[PageSpeed] 13

David Polhill wrote:

> If I include IdTCPConnection.pas in my project and remove the [Weak] annotation it works fine

If you keep a persistent reference to the IOHandler it'll work fine, without having to modify the Indy source.

-- 
Dave Nottage [TeamB]
0
Dave
7/4/2013 9:57:12 AM
> {quote:title=Dave Nottage wrote:}{quote}
> David Polhill wrote:
> 
> > If I include IdTCPConnection.pas in my project and remove the [Weak] annotation it works fine
> 
> If you keep a persistent reference to the IOHandler it'll work fine, without having to modify the Indy source.
> 
> -- 
> Dave Nottage [TeamB]

Thanks for that, but it's not my code that is creating the IOHandler.  The IOHandler is created on line 1267 in Soap.SOAPHTTPTrans.pas:

IndyHttp.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);

All I'm doing is executing a method on my SOAP object that is defined in the unit auto-generated by the WSDL importer.
0
David
7/4/2013 12:40:16 PM
David Polhill wrote:

> Thanks for that, but it's not my code that is creating the IOHandler. 

Sorry; yes, that's an issue that should be reported to QualityCentral.

-- 
Dave Nottage [TeamB]
0
Dave
7/4/2013 3:11:42 PM
David wrote:

> When running on iOS, the IndyHttp.IOHandler is nil after this line of
> code has been run.  This appears to be due to the fact that in
> IdTCPConnection.pas we have the line:
> 
> {$IFDEF USE_OBJECT_ARC}[Weak]{$ENDIF} FIOHandler: TIdIOHandler;

Yes.  Indy does not utilize TComponent.FreeNotification() under ARC for external 
component references.  It lets the RTL manage the references instead.  Using 
the [weak] attribute accomplishes the same thing as FreNotification() - letting 
TIdHTTP nil its FIOHandler member when the IOHandler object is freed external 
to TIdHTTP.  It is the caller's responsibility to ensure the source component 
remains alive for the lifetime of TIdHTTP as needed.

> So it must be that the object goes out of scope because of the weak reference.

Probably.  I think that line should assign TIdHTTP as the Owner, so there 
is an active reference:

{code:delphi}
IndyHttp.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(IndyHttp);
{code}

The SOAP code should do that anyway, because in non-ARC versions of Delphi 
that original code would be a memory leak as that IOHandler object would 
not be owned by anyone, not even the RTL, and thus not freed by anyone (unless 
the SOAP code is calling IndyHttp.IOHandler.Free() elsewhere).

> So, making the above change fixes my problem, but presumably the
> [Weak] annotation is there for a reason.

Yes, it is there for a reason.

> will my application now leak?

By removing the [weak] attribute, you change the FIOHandler variable into 
a strong reference, so the IOHandler object will be freed when that reference 
is cleared when TIdHTTP is destroyed (or a new IOHandler is assigned), as 
long as nothing else refers to that IOHandler object.  However, you would 
just have to watch out that the two objects do not have strong circular references 
to each other, otherwise neither object will be freed correctly (both of 
their refcounts will not fall to 0).

--
Remy Lebeau (TeamB)
0
Remy
7/5/2013 7:23:23 PM
Dave wrote:

> yes, that's an issue that should be reported to QualityCentral.

Agreed.

--
Remy Lebeau (TeamB)
0
Remy
7/5/2013 7:24:02 PM
Reply:

Similar Artilces:

iOS Webservice "IOHandler value is not valid."
got a problem when I try to access my web service via https. I get an exception in function TIdCustomHTTP.SetHostAndPort: TIdHTTPConnectionType; ..... ..... if not (IOHandler ice TIdSSLIOHandlerSocketBase) then begin *Raise EIdIOHandlerPropInvalid.Create (RSIOHandlerPropInvalid);* end; ..... ..... Read in the following IdCompilerDefines.inc {$ Ifdef CPUARM} {$ Ifdef IOS} {$ DEFINE USE_OPENSSL} / / RLebeau: For iOS, OpenSSL can not be used as an external library, it must / / Be statically linked into the app. Users who want to use Open...

Using "+" or "||"
Using SQLAnywhere 5.5.04, I've gotten into the habit of using "||" in ISQL to indicate a string concatenation. I needed to paste my SQL statement into the PowerBuilder script painter for some embedded SQL, and PB didn't like the "||" very much at all. I changed it to "+" and it seems to be ok. Do these two operators indicate ~exactly~ the same thing? moin, afaik these two's are not the same! if you're using "||" and any term is NULL then in the resultstring the term will be ignored if you use "+" then the resu...

"Using" or "With"
Hi all Please can someone enlighten to me as regards the difference with the "Using" and "With" statement when accessing data - which is better, what are the limitations and/or any pointers. Many thanks. Regards DaveDavid WinchesterPlease mark as answer if this is the solution.  using gives you the ability to use the connection and it closes the connection directlly after you finish using it. and there is no need to try- cach - finaly. there is no limitation on using USING keywordMuhanad YOUNISMCSD.NETMy Blog || My Photos || LinkedIn I have a dataobject the re...

"SSL" "Mail" and "Code"
Does anybody know of any discussions taking place within Mozilla regarding these 3 bits in the certificate manager? Perhaps I've missed something in the discussions here. In any case, I think a new mechanism for indicating trust w/in the Mozilla apps are needed. Take for example the "StartCom Certification Authority" root. The Certificate Manager (I'm using Firefox on Windows) says it can identify web sites, email users, and code yet the cert itself says it can only be used for signing other certs (essentially, that is). At a minimum this is confusing but I have...

DBD::Proxy::db table_info failed: Server returned error: Failed to execute method CallMethod: Can't use string ("1") as an ARRAY ref while "strict refs" in use
------_=_NextPart_001_01C2BB46.4379CEA8 Content-Type: multipart/related; type="multipart/alternative"; boundary="----_=_NextPart_002_01C2BB46.4379CEA8" ------_=_NextPart_002_01C2BB46.4379CEA8 Content-Type: multipart/alternative; boundary="----_=_NextPart_003_01C2BB46.4379CEA8" ------_=_NextPart_003_01C2BB46.4379CEA8 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I'm having a problem using the table_info() via ProxyServer... I'm = getting the following error messages: I am us...

Why do I get an error saying "SSL has been disabled" when my "use SSL 3.0" tab is checked?
The subject line says it all. This is happening in a new profile I just created. On 7/19/2010 1:15 PM, Restorm wrote: > The subject line says it all. This is happening in a new profile I just > created. Never mind. Turned out I had a corrupted Cert8.db file. All better now. ...

What can i store in viewstate using "ViewState(key) = value" & "Value = ViewState(key)"
Hi All   I am struggling to maintain user information accross a sequence of 4 pages now i'm trying to save data in viewstate till they can be transmitted to the next page   This code  ViewState(vPropertyRentalContactName) = "aa"   is not working   Hi, if you want to persist something across pages on a per user basis I would probably use the Session object instead. Please take a look at this article ASP.NET: Nine Options for Managing Persistent User State in Your ASP.NET Application to get a better view of what's possible. Grz, Kri...

"Use of uninitialized value" when clicking on "login again" link
We migrated a Bugzilla 2.20 installation from one server to another. Everything seems to work just fine, except when clicking on the "log in again" link after a logout. We get a "index.cgi: Use of uninitialized value in substitution (s///) at (eval 22) line 44" error message at the top of the page, but can re-log without any issues. When we click on the "Actions => Home" link instead of the propose "log in again" one, we do not get this error message and can re-log too. Any idea of what could happen (bad permission, and so on?). -- V...

Delphi 2007 assert
The assertion message from Delphi 2007 is... "(!"SetThreadContext failed")" in ..\win32src\thread32.cpp at line 412 Any way I can patch this out? CodeGearâ„¢ Delphi® 2007 for Win32® Version 11.0.2902.10471 El 18/01/2014 21:48, Michael Leahy escribió: > The assertion message from Delphi 2007 is... > > "(!"SetThreadContext failed")" in ..\win32src\thread32.cpp at line 412 > > Any way I can patch this out? > > CodeGearâ„¢ Delphi® 2007 for Win32® Version 11.0.2902.10471 > An unofficial fix fo...

"Failed to create AppDomain" error, after using "Copy Website"
I don't have IIS installed on my development machine. I don't see the IIS in Services in Control panel. I am using Visual Studio 2008 to develop websites. I think Visual Studio 2008 doesn't require IIS to run web applications! Using the "Copy Website" in Visual Studio 2008 I copied a website from my local development machine to a webhosting server. I connected to ftp site of the hosting company to do the copy. No problem there with the website on the hosting server and everything works fine on the hosting server. I can preview my site with no problem...

Filter records from datatable using Select() method and having "%" or "*" in value
Hi, I have a page, wherein a grid is bind with the datatable that I maintain in Session. I have also provided facility to filter the records. There is a textbox provided for that and the records are filtered using Select() method. The problem is that if a user inputs characters like % and * then Select() method gives error because these characters have special meaning. Even ' (single quote) has special meaning but I have used escape character single-quote and thus two single quote would not generate error. Can anyboday help me with this? How can escape the meaning of % and * in Select...

RE: Using "do" versus "use" for subroutine
Edward Wijaya wrote: > Hi, > > I would like to know which of this > is better and what is the pro and cons: > > 1. A file "mysub.pl" which stored > a subroutine, and later called by > main file using: do "mysub.pl" > > or > > 2. A file "mysub.pm" and called > in main file using : use "mysub.pm" The second construct is not valid; the argument to "use" must be a bareword. It's not really possible to answer your question without knowing more details. I'm not clear about what&#...

Replacing "use base" with "use parent"
--bcaec554da9c7514d304ca32ffa3 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi, From the base.pm documentation<http://perldoc.perl.org/base.html#DESCRIPTIO= N>: Unless you are using the fields pragma, consider this module discouraged in favor of the lighter-weight parent . From the parent.pm documentation<http://perldoc.perl.org/parent.html#HISTOR= Y> : This module was forked from base to remove the cruft that had accumulated in it. parent.pm is a 30 lines pure Perl dual module available also in core since 5.10...

ValidationGroup "group1", "group2" and "" (empty)
hi,i have 2 validationgroup (group1, group2 - 3 groups with the empty one) and 3 buttons. when i click the button at the end i wanted to validate group1, group2 and the empty one on client side and server side, but it does only validate the requiredfieldvalidator with the empty validationgroup property. 1) how can i validate all on client AND server side?2) how can i validate group1 and group2 (without the empty one) on client and server?Here is my code snippet: <div> <!-- group1 --> <asp:TextBox runat="server" ID="txtTest"></asp:TextBox&...

Web resources about - SOAP fails in iOS when using SSL ("IOHandler value is not valid.") - embarcadero.delphi.firemonkey

Resources last updated: 11/28/2015 12:05:41 PM