Program lockup while using tunnel - WeOnlyDo Discussion board

Program lockup while using tunnel (General questions)

by user6116, Wednesday, July 06, 2005, 18:51 (7079 days ago)

I downloaded the evaluation version of the SSHTunnel software. My idea was to integrate it into my Visual Basic application so I do not need to open a putty every time I want to connect to my database. Using the SSHTunnel, I can connect to the server. Then seperate applications can use that tunnel just fine. The problem occures when I try and connect to my database thru the same program that is creating the SSHTunnel. When I try to do that, it locks up my application. Here is the process I follow.
- Run application
- Connect to server via SSHTunnel
- Connect to database via ADODB Connection to PostGre server

When I run the application and omit step 2, i have to open up an SSH Tunnel with putty, but it runs good. If I run the application and omit step 3 but keep step 2, it will open a Tunnel that I can use with other applications (including the same application with step 2 omitted). So, basicly my question is... is there a reason that when I connect to the database via ADODB after I create the SSHTunnel within the same application that it locks up?

Re: Program lockup while using tunnel

by wodSupport, Wednesday, July 06, 2005, 20:40 (7079 days ago) @ user6116

Hi.

We know about this problem. It's because wodSSHTunnel and your DB connection runs in the same thread. Since your DB blocks the thread while trying to connect, wodSSHTunnel cannot process windows messages (and socket-related messages) and everything hangs.

You could solve this problem by

1. Trying to use wodSSHTunnel.EXE instead
2. Setting Threading = True
3. Moving any of these 2 components in separate thread (DB if possible)
4. Setting DB to work in non-blocking (async) mode

You could try any of above.

Let me know how it goes.

Re: Program lockup while using tunnel

by user6116, Thursday, July 07, 2005, 16:27 (7078 days ago) @ wodSupport

First, thank you for such a fast response. I am under a time crunch at my company and I am hoping to get this resolved soon. It seems that I may be a little inexperienced at this process, so bear with me. In your response, you suggested for me to try wodSSHTunnel.exe. Does that mean you want me to try using the ActiveX component? What I did in my application was, I added the ActiveX Component like the one you have in SSHTunnelSamplesVBActiveX1. Simple then I followed what you did and created the tunnel. But per your request, I tried setting threading = true and it did not change anything.

Your next two suggestions were:
3. Moving any of these 2 components in separate thread (DB if possible)
4. Setting DB to work in non-blocking (async) mode

I am not sure how to do that. I tried to pull up examples on the internet, but I was not successful. Is there anything that you have that can help me with this? Thank you!

Re: Program lockup while using tunnel

by wodSupport, Thursday, July 07, 2005, 16:41 (7078 days ago) @ user6116

I doubt you'll manage to do 4th scenario - this depends on DB client software, and usually they don't have async mode supported.

And 3th scenario is very hard to do. I suggest you check out following article

http://www.freevbcode.com/ShowCode.Asp?ID=4029

about doing threads in VB. Move DB connection method to such threaded environment and it will work. We had one client long time ago doing that, and it worked.

BTW if you use any other langauge than VB then you'll be safer with threads.