Announcement

Collapse
No announcement yet.

Can Miva Script use sockets?

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

    Can Miva Script use sockets?

    "And now for something completely different ..."

    I'm putting together a project that will connect a Miva store to an industrial-automation system, so that the store can send messages to the machines and receive status messages. The protocol for talking to the machines is reasonably simple, but the source code I've seen uses Internet "sockets" instead of the usual HTTP request/response API. Can a Miva module work with sockets?

    I must admit that I don't know much about sockets. From the code I've seen, they use a pretty basic "open, send, receive, close" form of communication. But I don't know how that relates to the sort of HTTP communication that MvCALL can do.

    I'll guess that, if there's no easier solution, I can write a PHP or Python script that will run on the store's server. It will accept incoming MvCALLs from the module, perform the communication via sockets, and pass the result back to the store as the reply to the MvCALL. Is that correct?

    I'm hoping that someone here has experience with this sort of hookup, and maybe can even send me a script that will do the job. Or maybe there's an open-source program that I can use. What do y'all think?

    Thanks --
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    #2
    It cannot; MvCall is specific to http requests, with/without ssl, port is configurable. From what you've described, an intermediary system is likely far more desirable, because it would receive communication from the store in the manner you want to move the relevant data, and can then both package that into the format needed by the target and add relevant error detection, logging, record responses, and communicate that data back to the store using API. Those types of systems are also often notoriously slow, so you may need your script configured to have an unusually long active connection and run time.
    David Hubbard
    CIO
    Miva
    [email protected]
    http://www.miva.com

    Comment


      #3
      Hi David, Thanks for the quick reply. I will off-load the HTTP-to-socket connector program to the client if I can. But the term "industrial" may be misleading; this is a pretty small project. The remote hardware consists of a router and a programmable controller. There is no "intermediate system" on which to run a connector program.

      From time to time, I've written PHP scripts to help with jobs that Miva modules can't do. So I know how to write a script that a module can communicate with via MvCALL. I just did some more reading, and it looks like it only takes about a page of code to open a socket connection, send a message, receive a reply, and close the connection. So this seems like a pretty easy thing for me to write.

      The client already has a prototype app that can talk to their machines, and it runs nice and fast. So I don't think timeouts will be a concern.

      Do you see any problems with this approach?

      Also, can I use Python on a Miva server, instead of PHP? The client's app is written in Python, so I'd prefer to use that if it's possible.

      Thanks for your help --
      Kent Multer
      Magic Metal Productions
      http://TheMagicM.com
      * Web developer/designer
      * E-commerce and Miva
      * Author, The Official Miva Web Scripting Book -- available on-line:
      http://www.amazon.com/exec/obidos/IS...icmetalproducA

      Comment


        #4
        Yep we can make Python scripts work via web request if they're otherwise set up for that type of use.
        David Hubbard
        CIO
        Miva
        [email protected]
        http://www.miva.com

        Comment


          #5
          Great! What do I need to do to get Python installed on one of my dev stores? Or is it already there by default?
          Kent Multer
          Magic Metal Productions
          http://TheMagicM.com
          * Web developer/designer
          * E-commerce and Miva
          * Author, The Official Miva Web Scripting Book -- available on-line:
          http://www.amazon.com/exec/obidos/IS...icmetalproducA

          Comment


            #6
            You'd need to choose the extension you'd like and then contact support to enable it.
            David Hubbard
            CIO
            Miva
            [email protected]
            http://www.miva.com

            Comment


              #7
              "Extension" meaning the filename extension, such as ."py?"

              Thanks --
              Kent Multer
              Magic Metal Productions
              http://TheMagicM.com
              * Web developer/designer
              * E-commerce and Miva
              * Author, The Official Miva Web Scripting Book -- available on-line:
              http://www.amazon.com/exec/obidos/IS...icmetalproducA

              Comment


                #8
                Correct
                David Hubbard
                CIO
                Miva
                [email protected]
                http://www.miva.com

                Comment

                Working...
                X