Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Alphas node express server post data problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Alphas node express server post data problem

    Has anybody got post data working in Alpha using node express server with script in node_services

    ....
    app.post('/solve', function (req, res) {
    var co = req.body;
    res.send(solve.calculate(co));
    });
    ...

    I have tested that code works in separate node express server without problems but with Alphas built in node express server the post path is for some reason index.htmsolve (gives 404-error) but it should be just solve. (index.htm is the file loaded from node express server)
    Everything else works as expected but the post part not.

    #2
    Re: Alphas node express server post data problem

    Solved.

    'use strict';
    (for some reason this syntax gives error in Alphas js-editor so you have to use third party editor as usually.)

    Also in this case you should use pretty urls to call index.htm page

    Comment


      #3
      Re: Alphas node express server post data problem

      Can some one, post a basic example of express server working in Alpha, please?

      If I consider express as a module, Alpha can't locate it in node_modules.

      Code:
      node_request("express",p2,.f.,.f.)
      Any ideas?

      Comment


        #4
        Re: Alphas node express server post data problem

        Do you use a load balancer? We built a websocket feature, but have discovered that the load balancer wasn't managing it properly, and I wonder if that's a factor for those here. Alpha's done all they can, which puts the ball in the ISP's court. Like many here, we use a shared balancer with Zebrahost. But because it's shared, our ability to configure it is quite limited. And a private load balancer is expensive. This week Zebrahost is testing another load balancer, which I hope will offer a solution.
        -Steve
        sigpic

        Comment


          #5
          Re: Alphas node express server post data problem

          Thanks for you reply.

          What I want from using express is to be able to define routes and implement a REST api in a simple and clear way.
          For example, users calls index.a5w page, which calls express module.
          The module 'express' process the request and redirect to the function which give the response, like the previous example in this thread.
          It is this possible to do with Alpha?

          Comment


            #6
            Re: Alphas node express server post data problem

            Originally posted by tiago View Post
            Can some one, post a basic example of express server working in Alpha, please?

            If I consider express as a module, Alpha can't locate it in node_modules.

            Code:
            node_request("express",p2,.f.,.f.)
            Any ideas?
            Your node_request function first parameter "express" is your node service file express.js This file you have to write self.

            The Node module you want to use you can install or copy to server root sub folder. Then you can require module in your express.js service.

            Comment


              #7
              Re: Alphas node express server post data problem

              Thanks Ken.

              From your post I did that but without success, the response is:

              {"_id":"55550a79-e6a8-4319-bf4b-4f4ff3d1e684","error":"Cannot find module 'express'","result":null}

              Ok, I will explain my setup.

              index.a5w
              Code:
              <!DOCTYPE html>
              <html>
              <head>
              <title>NodeJS - Express</title>
              </head>
              <body>
              
              <%a5
              debug(1)
              dim p2 as p
              p2.firstname = "John"
              p2.lastname  = "Presley"
              '?node_request("hello",p2,.f.,.f.)
              
              ?node_request("myexpress",p2,.f.,.f.)
              %>
              </body>
              </html>
              In folder Default.WebProject I have the folder "node" with:
              Code:
              node/
                node_service.js
                node_service/
                  hello.js
                  myexpress.js
              The hello module works ok.

              So the problem is in the myexpress.js, how to get the script var express = require("express");
              Since it is located in: C:\Program Files (x86)\a5V12\node_modules\express

              Do node.js need to setup the NODE_PATH ?

              Code:
              var eventId = 0;
              exports.handler = function(packet,response,sendResponse) {
              	var e;
              	try {
              	     var express = require("express");
              	     var app = express();
              	     var port = packet.port || 3700;
              	     //--------------------------------------------
              	     app.use('/*.a5w', function (req, res, next) {
              	     		var eventCallback = function(data) {
              	     			if( data.content ) {
              	     				res.send(data.content);
              	     			} else if( data.error ) {
              		       			res.send("ERROR: "+data.error );
              	       			} else {
              	       				res.send("Bad result packet, no content or error defined." );
              	       			}
              	     		};
              	     		++eventId;
              	     		console.log('Callback to a5');
              	     		sendResponse( { _id : ("event."+eventId) , _command : "a5w" , url : req.originalUrl } , null , eventCallback );
              	     });
              	     //--------------------------------------------
              	     app.get("/", function(req, res) {
              			res.send("Root handler");
              	     });
              	     app.listen(port);
              	     response.result = "Listening on port " + port
              	} catch( e ) {
              	    response.error = e.message;
              	}
              	sendResponse(response);
              };

              Comment


                #8
                Re: Alphas node express server post data problem

                Error tells that node service do not find express module.

                You do not have node_modules folder in node folder. Put inside node_modules folder the node express module. (copy from Alpha install directory or use npm)

                Comment


                  #9
                  Re: Alphas node express server post data problem

                  It works now Ken.
                  Thank you so much.

                  The result is:
                  http://localhost:3700/
                  Root handler

                  I will explore this very important Alpha new feature (but hidden and undocumented feature).

                  Just another question:
                  It's normal the following behavior then I just refresh web page?
                  {"_id":"df23a2a9-0c9e-4314-9e65-2e572c2bdd0a","error":"","result":"Listening on port 3700"}
                  { "id" : "a06d8ad1-ea00-4622-a904-c826591dbe47" , "error" : "node stopped running" }


                  When I refresh the web page, it oscilate between an error and a normal result...

                  Comment


                    #10
                    Re: Alphas node express server post data problem

                    node_request function is just a wrapper function to the original xbasic node dim n as helper::v8 and so on syntax.
                    node_request use root folder the other syntax Alphas install folder.

                    Error is error.

                    Comment


                      #11
                      Re: Alphas node express server post data problem

                      So I have this going in a another thread but to keep things simple, is it possible that node.js services will be rendered broken because my server was recently converted to HTTPS? I can run the node.Js services perfectly fine when on my server and in working preview within Alpha development but when I try and run them from published components or pages it looks like the NodeRequest() isn't occurring, any ideas on a fix?

                      Comment


                        #12
                        Re: Alphas node express server post data problem

                        I am using reverse proxy frontend with AA server so SSL is installed to reverse proxy. That in my case means that node ( and AA server) is running all the time localhost for example node 127.0.0.1:3000 but I call it https://myserver.com:4430/index.htm . I can also call it without ssl for example http://myserver.com:3001/index.htm so reverse proxy supports dual host.

                        Comment


                          #13
                          Re: Alphas node express server post data problem

                          Originally posted by kkfin View Post
                          I am using reverse proxy frontend with AA server so SSL is installed to reverse proxy. That in my case means that node ( and AA server) is running all the time localhost for example node 127.0.0.1:3000 but I call it https://myserver.com:4430/index.htm . I can also call it without ssl for example http://myserver.com:3001/index.htm so reverse proxy supports dual host.
                          I'm using zebrahost and they are the ones that set up the SSL (I've sent their support an email hoping they may know of what is causing the issue), but I'm not sure how I would go about implementing what you've stated above as I don't know where they installed the SSL too (and not sure how I go about finding it on the server)?

                          Comment

                          Working...
                          X