dcsimg
Results 1 to 17 of 17

Thread: Web Interface for my VB6 app FastCGI

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Posts
    276

    Web Interface for my VB6 app FastCGI

    Hello Group,

    I am looking for a clear explanation of this: https://github.com/jpbro/VbFcgi

    What is needed?
    What does NGinx do?
    A simple example of pressing a button on webpage and activating in software.

    For the post part I really do not need to send classes/object to web page, I just need to duplicate the user interface in VB6 to webpage.

    Sorry for the newbie question, I looked through the docs, but would really like a overview to understand if this is a path I should explore.

    thanks!

  2. #2
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,102

    Re: Web Interface for my VB6 app FastCGI

    It's a backend framework, that allows you to use VB6 to develop with (via FCGI).

    It really has nothing to do with duplicating a user interface (or any user interface), and if you don't already understand basic web development - you might be in over your head.

    Basically NGINX is the server app (vaguely equivalent to IIS/Apache). It can handle things like directing a web request to your FCGI app.

    A round trip looks kind of like this.
    Someones Browser Request --> Internet --> Your Server --> NGINX --> FCGI/VB6 --> HTML text response --> NGINX --> Internet --> Browser.

    So VB6 sits in the middle there, processing the request / cookies etc, and sends a text/html response back.

    If you want a UI - that has to be part of the HTML you're sending back.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Posts
    276

    Re: Web Interface for my VB6 app FastCGI

    Quote Originally Posted by DEXWERX View Post
    It's a backend framework, that allows you to use VB6 to develop with (via FCGI).

    It really has nothing to do with duplicating a user interface (or any user interface), and if you don't already understand basic web development - you might be in over your head.

    Basically NGINX is the server app (vaguely equivalent to IIS/Apache). It can handle things like directing a web request to your FCGI app.

    A round trip looks kind of like this.
    Someones Browser Request --> Internet --> Your Server --> NGINX --> FCGI/VB6 --> HTML text response --> NGINX --> Internet --> Browser.

    So VB6 sits in the middle there, processing the request / cookies etc, and sends a text/html response back.

    If you want a UI - that has to be part of the HTML you're sending back.
    I have done some apps in PhoneGap so I have limited understanding.

    What my goal is to create a duplicate of my user interface in HTML and then get state through fastCGI. I assume that is possible.

    WP

  4. #4
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,102

    Re: Web Interface for my VB6 app FastCGI

    it's possible, and not difficult if you already have a good grasp of web apps.
    I recommend creating a form by hand using the Bootstrap framework.

    beyond that - you're going to have to read some basic tutorials.
    Try setting up the example project JP provided.
    Check how he responds to different requests (GET/POST etc.)

    And try and shim your form into that project.

  5. #5
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,108

    Re: Web Interface for my VB6 app FastCGI

    Thanks for stepping in Dexwerx, everything you said is correct

    I'll just add a bit of detail:

    Quote Originally Posted by axisdj View Post
    I am looking for a clear explanation of this: https://github.com/jpbro/VbFcgi

    What is needed?
    There are a few different "layers" of requirements.

    First, you need a web server that supports the FastCGI protocol. For the purposes of the development of the VBFCGI framework, I've exclusively used Nginx because:

    • It supports FastCGI backends.
    • It is free and open-source.
    • It is a standalone executable, so it's easy to use for testing purposes on my development machine (and easy to distribute to other machines if necessary.


    You can use any other web server software that supports FastCGI pass through to backend application servers though. I don't have experience with any others though, so you will need to do your own research if you choose not to use Nginx.

    Next, you need to make sure that your webserver is configured to pass queries through to your FastCGI application host. In Nginx this might look like this (in your nginx.conf file):

    Code:
    http {
    	upstream backend {
    		# Load-balancing across multiple FCGI listeners defined below
    		server localhost:9100;
    	}
    
        include       mime.types;
        default_type  application/octet-stream;
    
        access_log  logs/access.log;
        error_log	logs/error.log error;
    	
        sendfile        on;
    
        keepalive_timeout  65;
    
        server {
            listen       80;
            server_name  localhost;
    
            location / {
                root   html;
                index  index.html index.htm;
            }
    
            # pass the FCGI scripts to FastCGI server listening on upstream "backend"
            location ~ \.(fcgi|vbml)$ {
                root           html;
    			fastcgi_keep_conn on;
    			fastcgi_pass backend;
    			fastcgi_index index.html;
    			fastcgi_split_path_info ^(.*cgi)(/.*)$;
    			fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
    			fastcgi_param PATH_INFO $fastcgi_path_info;
    			fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    			include fastcgi_params;
            }
    
        }
    }
    The above configuration sets up Nginx to listen on localhost (127.0.0.1) port 80. It also tells Nginx that there is a single upstream server called "backend" listening on localhost port 9100 (this is the FCGI application host server). Lastly, it tells Nginx to pass FCGI requests to "backend" via the [i]fastcgi_pass backend;[i] setting.

    With the above configuration, Nginx will consider any web request it receives that ends in ".fcgi" or ".vbml" to be "FCGI" requests destined for the "backend" FCGI application server at localhost:9100. All other requests will be treated as regular web requests against the root folder. This allows you to serve both static and dynamic content.

    Next you need a running instance (or instances) of the VBFCGI application server. This is achieved by running the vbfcgihost.exe and specifying a host and port to listen on. To work with the above example, you would use the following command line:

    Code:
    vbfcgihost.exe /host localhost /port 9100 /spawn 1
    The above will spawn a single listener on localhost:9100.

    Lastly, you need you FCGI application. This is a VB6 ActiveX DLL with a class called CFcgiApp in it.

    The DLL must reference included VbFcgiLib.dll

    The CFCgiApp class must implement the VbFcgiLib.IFcgiApp interface. This is done by putting the following at the top of your CFcgiClass General section:

    Code:
    Implements VbFcgiLib.IFcgiApp
    The CFcgiApp class must also then include the IFcgiApp ProcessRequest method as follows:

    Code:
    Private Sub IFcgiApp_ProcessRequest(po_Request As VbFcgiLib.CFcgiRequest, po_Response As VbFcgiLib.CFcgiResponse)
    In the IFcgiApp_ProcessRequest app, you can kick off any dynamic processing that you'd like (based on what you receive in the po_Request object) and pass that back downstream to the browser using the po_Resonse object. This is the part where the sky's the limit, and it's difficult to tell you what to do unless you have some specific questions about what you are trying to do, but essentially you can use any non-visual (not form/usercontrol based) VB6 code here to help you build a serve dynamic data back to a browser (HTML, JSON, XML, binary files, etc...)

    Quote Originally Posted by axisdj View Post
    What does NGinx do?
    Hopefully that's a bit clearer now, but in a sentence: Nginx acts as a b between your VB6 FCGI application and a web browser.

    Quote Originally Posted by axisdj View Post
    A simple example of pressing a button on webpage and activating in software.
    I recommend taking a look at the included VbFcgiDemoApp.CFcgiApp code - it has an example of clicking a button and sending back randomly generated JSON data to the browser which then displays it in a table.

    Quote Originally Posted by axisdj View Post
    For the post part I really do not need to send classes/object to web page, I just need to duplicate the user interface in VB6 to webpage.
    This will be the tricky part - there is no conversion of existing forms or anything to a web page (at least not at this point). You would have to build your own HTML forms that look similar to your VB6 forms. Once that is done you could exchange information between your HTML forms and your VB6 forms over the web via FastCGI.

    Hope that helps, but let me know if you have any further questions!

  6. #6
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,108

    Re: Web Interface for my VB6 app FastCGI

    Quote Originally Posted by DEXWERX View Post
    it's possible, and not difficult if you already have a good grasp of web apps.
    I recommend creating a form by hand using the Bootstrap framework.

    beyond that - you're going to have to read some basic tutorials.
    Try setting up the example project JP provided.
    Check how he responds to different requests (GET/POST etc.)

    And try and shim your form into that project.
    Good idea...I'll try to put an HTML <> VB6 form demo in my demo app soon. I think the key will be to make sure you don't ever show the form, but you can Load it and then populate the controls based on what you receive from the browser.

    If your form shows an MsgBoxes (or other forms, etc...) that would potentially cause problems, so there might be some extra work on your form code to add a "UIless" flag and make sure you don't show any forms/msgboxes when it is set to True. That's a bit ugly, but unless you have already separated most of your logic into classes and are just using your Forms for UI, then its probably the only way?

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,816

    Re: Web Interface for my VB6 app FastCGI

    i am not at all sure if it is relevant here, but i vaguely remember some thread by dilettante, where he did an example of using .hta forms for a vb6 interface
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  8. #8
    Lively Member
    Join Date
    Feb 2015
    Posts
    115

    Re: Web Interface for my VB6 app FastCGI

    Quote Originally Posted by axisdj View Post
    I have done some apps in PhoneGap so I have limited understanding.

    What my goal is to create a duplicate of my user interface in HTML and then get state through fastCGI. I assume that is possible.

    WP
    I'd suggest looking at NSBasic for your client app/user interface.

    It is a VB6-like language with a VB6-like IDE. There are controls in the IDE that are similar to those in VB6, and a form designer like VB6. You can even copy and paste VB6 code into NSBasic.
    NSBasic then generates JavaScript/HTML mobile (iOS and Android) and web apps.
    NSBasic supports PhoneGap.

    NSBasic claim to have over 1 million users.

  9. #9
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,108

    Re: Web Interface for my VB6 app FastCGI

    I've done a bit of work on a demo to show how you can get data from a VB6 form downstream to a web browser using the VbFcgi framework.

    I have a bit of cleanup to do, but I will try to get this published to the VBFcgi GitHub repository soon.

    In the meantime here's a screenshot

    Name:  Web VB6Form Interfacing.jpg
Views: 165
Size:  47.3 KB

    Note that while this is "doable" I can't really recommend it except as a stop gap measure. Ideally you would be moving your code out to separate public Class modules in a DLL and then calling methods in that DLL to populate your web pages AND VB6 forms.

  10. #10
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,108

    Re: Web Interface for my VB6 app FastCGI

    I just published the Browser <> VB6 Form interfacing demo (as described in post #9) to GitHub for those that are interested in checking it out.

  11. #11
    Frenzied Member
    Join Date
    Sep 2012
    Posts
    1,105

    Re: Web Interface for my VB6 app FastCGI

    It seems that Olaf said he could dynamically load client-side interfaces via RC5.cActiveScript, I don't know if this interface is a VB6 form or a WebBrowser page.

  12. #12
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,108

    Re: Web Interface for my VB6 app FastCGI

    Quote Originally Posted by dreammanor View Post
    It seems that Olaf said he could dynamically load client-side interfaces via RC5.cActiveScript, I don't know if this interface is a VB6 form or a WebBrowser page.
    What exactly are you hoping to be able to do? I think the first step should be to get on the same page regarding your goals vs. the goals of the VBFCGI framework.

    For my side, I don't think I want to be converting VB6 forms directly into web pages - I think the web and legacy desktop apps are 2 distinctly different things that have different requirements re: appearance, layout, etc... but I think they can share the same back-end code and that back-end code can be written in VB6. That's been the goal of the framework so far at least.

    The Browser<>VB6Form demo was developed to provide an incremental upgrade path for those legacy projects where a lot of code is in Forms as opposed to class modules and standard modules. For new projects, I definitely recommend coding as much as possible in modules, and then the front-end UI (forms or web pages) can be written to work with that common base of back-end code.

  13. #13
    Frenzied Member
    Join Date
    Sep 2012
    Posts
    1,105

    Re: Web Interface for my VB6 app FastCGI

    Quote Originally Posted by jpbro View Post
    What exactly are you hoping to be able to do? I think the first step should be to get on the same page regarding your goals vs. the goals of the VBFCGI framework.

    For my side, I don't think I want to be converting VB6 forms directly into web pages - I think the web and legacy desktop apps are 2 distinctly different things that have different requirements re: appearance, layout, etc... but I think they can share the same back-end code and that back-end code can be written in VB6. That's been the goal of the framework so far at least.

    The Browser<>VB6Form demo was developed to provide an incremental upgrade path for those legacy projects where a lot of code is in Forms as opposed to class modules and standard modules. For new projects, I definitely recommend coding as much as possible in modules, and then the front-end UI (forms or web pages) can be written to work with that common base of back-end code.
    Hi jpbro, I totally agree with you, and I don't need what axisdj is asking for. My request is simple:

    Step 1: Download Json data or binary data from FastCGI to the VB6 TextBox, this step is mainly used to test the data.

    Step 2: Use OpenUI to display the dynamic HTML data processed by FastCGI on Web-Brower.
    This step is exactly the same as what you said above. It's just that I'm not familiar with OpenUI yet and I'm learning.

    In fact, as long as the first step(step 1) is successful, my goal is achieved.

  14. #14
    PowerPoster
    Join Date
    Feb 2006
    Posts
    19,244

    Re: Web Interface for my VB6 app FastCGI

    Why not just rewrite as an HTA or use something like Electron or NW.js?

    Unless you are trying to create a web site and want the burden of keeping a server online so your application doesn't evaporate in a few weeks or years I'm not sure how any server implementing FastCGI helps you. If you do want this then you can always just use classic ASP at the server to host your VB6 DLLs. FastCGI was a hack to work around the high overhead of CGI. It isn't anything magical and has its own overhead, and is mainly used today to make PHP more stable since it isn't thread-safe enough to be reliable as an ISAPI Extension.

    Electron Quick Start

  15. #15
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,108

    Re: Web Interface for my VB6 app FastCGI

    Quote Originally Posted by dilettante View Post
    Why not just rewrite as an HTA or use something like Electron or NW.js?
    Electron Quick Start
    This is just one person's opinion, but it's a sentiment I've heard from many people who use Electron apps: Electron is Cancer

    Anyway, here's my rationale from the last time you asked this question...I was only about 2 years late on my reply, so maybe you missed it

    http://www.vbforums.com/showthread.p...=1#post5235465

  16. #16
    PowerPoster
    Join Date
    Feb 2006
    Posts
    19,244

    Re: Web Interface for my VB6 app FastCGI

    Quote Originally Posted by westconn1 View Post
    i am not at all sure if it is relevant here, but i vaguely remember some thread by dilettante, where he did an example of using .hta forms for a vb6 interface
    Re-reading his posts several more times it sounds like what he wants is something that magically turns a single-user VB6 desktop GUI program into a multi-user server hosted web application.

    I don't think I showed anything about using an HTA to front-end compiled VB6 code. Easy enough I suppose though aside from some quirks of HTML and its script execution model. The script could be quite minimal, mainly calling methods and handling any events raised by objects in a VB6 ActiveX DLL.


    I might post an example of something small but non-trivial in the CodeBank later. But I'm sort of tired of having code ripped off here and reposted to other sites under the crook's name.

    I'm beginning to think Olaf has the right idea. Since the remaining dregs of the VB6 community have so few scruples maybe the only way to share code is to provide precompiled binaries and keep the source closed. Documentation is very helpful, but with so few but copy/paste cowboys remaining who don't read anyway, why bother?

    Since you can't post binaries without the source here I suppose the CodeBank is going to shrink down to rare posts of tiny snippets stolen from somewhere else. Basically we're down to bombed-out ghetto status here now, with a lot of rubble and a few petty gangsters mugging and beating on the few honest folks still living here. The rule is "If you don't want code ripped off out of hand then don't post any."

    Name:  VB6 Ghetto.jpg
Views: 109
Size:  28.3 KB

    What have we come to?

  17. #17
    Frenzied Member
    Join Date
    Sep 2012
    Posts
    1,105

    Re: Web Interface for my VB6 app FastCGI

    Quote Originally Posted by dilettante View Post
    Why not just rewrite as an HTA or use something like Electron or NW.js?

    Unless you are trying to create a web site and want the burden of keeping a server online so your application doesn't evaporate in a few weeks or years I'm not sure how any server implementing FastCGI helps you. If you do want this then you can always just use classic ASP at the server to host your VB6 DLLs. FastCGI was a hack to work around the high overhead of CGI. It isn't anything magical and has its own overhead, and is mainly used today to make PHP more stable since it isn't thread-safe enough to be reliable as an ISAPI Extension.

    Electron Quick Start
    Hi dilettante, thanks for your advice and the information you provided. In order not to hijack the OP's thread, I'll post a new thread to discuss the best Web-Solution for VB6.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width