Anyway around this?

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
jscoulter
Posts: 14
Joined: Mon 09 Feb 2009 12:19

Anyway around this?

Post by jscoulter » Tue 15 Sep 2009 10:07

I have been using SecureBridge for a while now, and one thing that irritates me is when something is happening, say I am running this line of code:

Result:=ScSSHShell.ExecuteCommand(sCommand);

and it take a few seconds for a result to come back, the application just freezes while it waits.
You might at this point suggest using nonblocking mode, and yes that a good idea, however, its not just this area that causes the app. to freeze.
When you connect and for whatever reason the server is not availible bease of a wrong IP or its just off line, then this also freezes the application.

Is there a work-around for this? I have tried a few things, but maybe the controls are just not threaded which is the issue.
I am keen to know, as it actually causes a few issues for use.

Thanks, Jeremy

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Re: Anyway around this?

Post by Dimon » Tue 15 Sep 2009 13:22

jscoulter wrote:I have been using SecureBridge for a while now, and one thing that irritates me is when something is happening, say I am running this line of code:

Result:=ScSSHShell.ExecuteCommand(sCommand);

and it take a few seconds for a result to come back, the application just freezes while it waits.
To solve the problem you can use the NonBlocking mode by setting the ScSSHShell.NonBlocking property to True. You can find more detailed information about it in the SecireBridge help.
jscoulter wrote:When you connect and for whatever reason the server is not availible bease of a wrong IP or its just off line, then this also freezes the application.
Thank you for information. We have reproduced this problem and fixed it. This fix will be included in the next SecireBridge build.

jscoulter
Posts: 14
Joined: Mon 09 Feb 2009 12:19

Post by jscoulter » Tue 15 Sep 2009 19:33

I did say in my origial post "You might at this point suggest using nonblocking mode" and hey, you did ! So I thought that might actually show that I am AWARE of a solution.
Is there though nothing you can do in the code "like" application.processmessages so that even when nonblocking mode is false and your code is waiting for a response that it doesnt tie up the process?
The problem with nonblocking mode of course you sometimes get other data you dont need and you have to filter it where as in blocking mode you are getting the data from the command you are executing.

when you say "Thank you for information. We have reproduced this problem and fixed it. This fix will be included in the next SecireBridge build." is this the release same you mention in another post back on September the 1st in the following message http://www.devart.com/forums/viewtopic.php?t=15698
Is there a time frame for the release.

Jeremy

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 16 Sep 2009 07:53

jscoulter wrote:Is there though nothing you can do in the code "like" application.processmessages so that even when nonblocking mode is false and your code is waiting for a response that it doesnt tie up the process?
We can't use the Application.ProcessMessages method because this component can be used in service application, that doesn't allow using this way.
jscoulter wrote:when you say "Thank you for information. We have reproduced this problem and fixed it. This fix will be included in the next SecireBridge build." is this the release same you mention in another post back on September the 1st in the following message http://www.devart.com/forums/viewtopic.php?t=15698
Is there a time frame for the release.
Yes, I meant this build. The SecureBridge build where the problem is solved will be released by the end of this week.

jscoulter
Posts: 14
Joined: Mon 09 Feb 2009 12:19

Post by jscoulter » Wed 16 Sep 2009 08:04

fair enough.
Heres a wee tip. Maybe this will help.
Like you said Aplication.processmessages is not availible in a service, so whenI write a service I use the following:-

procedure TJeremysService.ProcessMessages;
var
Msg: TMsg;
begin
if PeekMessage(Msg, 0, 0, 0, PM_REMOVE) then
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end;

Instead of application.processmessages, I just call my function "ProcessMessages;" which works well.

Maybe its worth trying?

Jeremy

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 18 Sep 2009 06:59

We can't support such functionality, because that solution can cause different problems in service application. Using not NonBlocking mode assumes that the method will not return control until a command is not executed.

In order to solve the problem you can call the ExecuteCommand method in another thread.

Please, describe in more details why you don't use the NonBlocking mode.

jscoulter
Posts: 14
Joined: Mon 09 Feb 2009 12:19

Post by jscoulter » Fri 18 Sep 2009 07:16

maybe you could explain WHAT issue this causes in service applications? This function is designed to work IN service applications and I use it in many servie applications with no issues at all.
To call the execute method in thread makes no difference, I have tired.

The reason I dont use non blocking mode is simple. If I execute a command I get the result back in the same function its called from.
I Then dont have to add process overhead by calling repeat/until waiting for a reply in another event.
ITs far easier to work when executing scripts one after another.

Jeremy

jscoulter
Posts: 14
Joined: Mon 09 Feb 2009 12:19

Post by jscoulter » Fri 18 Sep 2009 08:00

also, another reason for nonblocking being false, I just remembered that there are infact commands I run the server that have NO output....as I just found now doing some testing. That is out of my control, so that is another reason :-)

Jeremy

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 18 Sep 2009 08:51

jscoulter wrote:also, another reason for nonblocking being false, I just remembered that there are infact commands I run the server that have NO output....as I just found now doing some testing. That is out of my control, so that is another reason :-)
I did not fully understnad what you mean?

Note: Depending whether the NonBlocking property is True or False, commands on SSH server are executed in different ways. Please check that you get the same result when you use both ways.

jscoulter
Posts: 14
Joined: Mon 09 Feb 2009 12:19

Post by jscoulter » Fri 18 Sep 2009 09:05

Ok I will make it clearer.
I can call a command on the server, and it gernerates NO RESULT i.e. there is no output from calling the command on the server.
So, OnAsyncReceive is not fired because there is nothing returned.
Trust me I have just been testing this !
So, if nonblocking is set to false, when the command has executed, it completes even though nothing is returned. The fact that nothing is returned may be a positive result, i.e. the command executed correctly because a result might onkly be returned on an error executing the commmand.

IF I set nonblocking to true then go writestring('mycommand') which has no result from running like so:

***************************************************
repeat
application.processmessage
until sResponse ''

procedure ScSSHShell1AsyncReceive(Sender: TObject);
begin
sResponse:=ScSSHShell.ReadString;
end;
***************************************************
th app just just sits there because there is nothing returned.

However, if I do Result:=ScSSHShell.ExecuteCommand('mycommand'); with nonblocking to false its maks no difference if there is data in he result or not....the command was executed.

Does that make it a bit clearer?? :-)

Jeremy

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 18 Sep 2009 12:34

I understand your question, but in any case we can't use the ProcessMessages method.
To solve the problem you should execute the ExecuteCommand method in another thread.

jscoulter
Posts: 14
Joined: Mon 09 Feb 2009 12:19

Post by jscoulter » Fri 18 Sep 2009 21:39

well, maybe I wll jut have to upgrade to source code version and fix it myself hehehe ;-)

Threads dont really solve the problem very well which is why I stated this whole thing off.
However, I have had a thought that MIGHT help solve part of my problem for commands that have no reply.

Is the new release going tbe made this weekend?

Jeremy

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 24 Sep 2009 08:47

New build of SecureBridge version 2.60.0.11 with Embarcadero RAD Studio 2010 support is available for download now.

Post Reply