Perl, Ruby, Python, C++ for websocket testing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Krik
    Junior Member
    • Jan 2012
    • 5

    Perl, Ruby, Python, C++ for websocket testing

    That title is going to seem a bit odd but let me explain. First, I would guess that the dathorn servers are not going to allow any script to run indefinitely to listen for websocket connections. However, I am hoping that they will allow it run for a few minutes at a time so I can just use it for testing (eventually I'll just get a VPS).

    But to get any script to run in the background I need to first figure out why I can't get in using SSH. I did create the public and private keys, "authorized" the public key, and downloaded both files. I tried using the Java based SSH console included in cPanel, I also tried using FireSSH (firefox addon) and when prompted I provided them with the private key. The java console just sat there and did nothing, but max out my cpu for 5 minutes, till I exited the page. The FireSSH told me authentication failed. I tried deleting and making new keys but it still didn't work. I haven't had a good reason to use SSH till now and with the warning, about account termination, that is in the SSH section I am also hoping there is good place to find some relevant documentation.

    Now to the rest of the problems. I have built a websocket server with php, that runs fine with wamp on my computer. But to build it to simulate multithreading I would need to use the pcntl_fork function, which needs a *nix server, which is why I needed the SSH (and will still need for any other language). But as I understand php is a poor choice, speed and resource wise, for a large number of concurrent connections, I thought I should look into using another languages.

    Now I have been using php and javascript for over 10 year and have had occasion to dabble in languages like LUA, C++, and C#. So picking up another language is not going to be an issue. The problem I am hitting is getting them to run. Too keep it a simple as possible I am just using simple "Hello World" scripts.

    Here's the perl script I am trying, just copied and pasted it from a tutorial
    Code:
    #!/usr/bin/perl -w
    
    use strict;
    
    my $message = "Hello, world!";
    
    print "Content-type:text/html\n\n";
    
    print <<HTMLSTOP
    <html>
    <body>
    $message
    </body>
    </html>
    HTMLSTOP
    I have changed the permission on the file to allow it to be executed and read (755), I have tried it in and out of the "cgi-bin" folder, and I have tried changing the first line to point the perl folder in the account (../perl). All are giving me this error
    lscgid: execve():/home/[accountname]/public_html/HelloWorld.pl: Permission denied
    I also tried ruby and the same thing happened, even if I used the .cgi file extension. Searching Google turned up very little on what that error means. It's so bad that the search term "ruby lscgid execve() Permission denied" gave only 7 results. Completely stunned me that Google had so utterly failed to find the solution.

    So I would guess some how I am not pointing to the perl or ruby directories properly or the file is not in the correct location.

    Also is there some way to avoid having to change the permission every time you upload the file. When testing I have been know to upload the same file hundreds of times and some of my bigger php project have had hundreds of files. I can't imagine having to build a web application in perl or ruby I think I would go insane.

    Last I wanted ask about using Python and C++. First is python setup on basic web hosting accounts, or can it be used through a 3rd part module (not preferred but good to know)? And I assume C++ is allowed but with the problems with perl and ruby I figure I would have the same issues with it, anything I need to know there?

    Any advice is appreciated. Sorry about he long post but I try not to ask questions till I have exhausted all possibilities, which usually results in a lot more questions.
  • AndrewT
    Administrator
    • Mar 2004
    • 3653

    #2
    Originally posted by Krik
    That title is going to seem a bit odd but let me explain. First, I would guess that the dathorn servers are not going to allow any script to run indefinitely to listen for websocket connections. However, I am hoping that they will allow it run for a few minutes at a time so I can just use it for testing (eventually I'll just get a VPS).
    Sorry, we cannot allow this at all.

    Originally posted by Krik
    But to get any script to run in the background I need to first figure out why I can't get in using SSH. I did create the public and private keys, "authorized" the public key, and downloaded both files. I tried using the Java based SSH console included in cPanel, I also tried using FireSSH (firefox addon) and when prompted I provided them with the private key. The java console just sat there and did nothing, but max out my cpu for 5 minutes, till I exited the page. The FireSSH told me authentication failed. I tried deleting and making new keys but it still didn't work. I haven't had a good reason to use SSH till now and with the warning, about account termination, that is in the SSH section I am also hoping there is good place to find some relevant documentation.
    Use an actual SSH client such as PuTTY and simply connect using your cPanel username and password.

    Originally posted by Krik
    Now to the rest of the problems. I have built a websocket server with php, that runs fine with wamp on my computer. But to build it to simulate multithreading I would need to use the pcntl_fork function, which needs a *nix server, which is why I needed the SSH (and will still need for any other language). But as I understand php is a poor choice, speed and resource wise, for a large number of concurrent connections, I thought I should look into using another languages.
    For testing /development purposes I would highly recommend you setup a local virtual machine of some *nix install. VirtualBox is very easy to use for this and free.

    Originally posted by Krik
    Now I have been using php and javascript for over 10 year and have had occasion to dabble in languages like LUA, C++, and C#. So picking up another language is not going to be an issue. The problem I am hitting is getting them to run. Too keep it a simple as possible I am just using simple "Hello World" scripts.

    Here's the perl script I am trying, just copied and pasted it from a tutorial
    Code:
    #!/usr/bin/perl -w
    
    use strict;
    
    my $message = "Hello, world!";
    
    print "Content-type:text/html\n\n";
    
    print <<HTMLSTOP
    <html>
    <body>
    $message
    </body>
    </html>
    HTMLSTOP
    I have changed the permission on the file to allow it to be executed and read (755), I have tried it in and out of the "cgi-bin" folder, and I have tried changing the first line to point the perl folder in the account (../perl). All are giving me this error

    I also tried ruby and the same thing happened, even if I used the .cgi file extension. Searching Google turned up very little on what that error means. It's so bad that the search term "ruby lscgid execve() Permission denied" gave only 7 results. Completely stunned me that Google had so utterly failed to find the solution.

    So I would guess some how I am not pointing to the perl or ruby directories properly or the file is not in the correct location.
    If you submit a ticket we can take a look at the Perl script. We do not provide support for Ruby, C/C++, Python, etc. Access to C compilers is disabled entirely. You'll find Ruby and Python binaries on the servers but these are provided as-is and not necessarily for web accessible scripts.

    Originally posted by Krik
    Also is there some way to avoid having to change the permission every time you upload the file. When testing I have been know to upload the same file hundreds of times and some of my bigger php project have had hundreds of files. I can't imagine having to build a web application in perl or ruby I think I would go insane.
    umask is used to set default permissions.

    Comment

    • Krik
      Junior Member
      • Jan 2012
      • 5

      #3
      Thanks for taking the time to reply, especially seeing how long my post was.

      I am kind of surprised by the reply to the use of websockets. Is there any plan to support them in the future? Without much doubt I would expect, at the very latest, within the next year they will be a major part of any good web developers set of tools. As compared to someone using an AJAX solution, or long-polling, I would think it would be more advantageous for you to support websocket. I would think you could even charge a bit more to add the feature, I'd pay it, as it would beat having to pay for a VPS, just to do testing on.

      Thanks for the suggestion on the virtual machine. I actually have some old PC's sitting around I could setup a linux server on, one may even still have a version of Linux. But any how, I have setup Linux (and windows) servers in the past and I am just not to keen on having to do that.

      So with that said I think I am going to go look into a VPS, its just less of a headache than most other options at the moment

      Don't worry I do plan to keep my account here (can't beat the customer service). If nothing else it will work as a place to do automated backups of the VPS.

      Comment

      • AndrewT
        Administrator
        • Mar 2004
        • 3653

        #4
        You're very welcome. There are no plans to support them at this time. You're the first to even mention them and as of right now there isn't a great way to permit this effectively in a shared hosting environment. Most sites using shared hosting really wouldn't have a need for the performance increase that they offer over AJAX, etc. anyways. Regardless these are fairly new as it is and only time will tell how well and to what extent they are adopted.

        Comment

        • ZYV
          Senior Member
          • Sep 2005
          • 315

          #5
          The requirement of keeping a hanging process to handle requests is inherent to the Websockets technology and I doubt there is even a way to have this to play nice with the shared hosting environment. Just get yourself a Virtuozzo-based VPS to play with, for such purpose it's largely enough...

          Comment

          Working...