Skip to content

TriremeServlet Node js import external websocket libraries  #177

Open
@kthyagaraj

Description

@kthyagaraj

Apologies if this is not the right place to ask question, i wouldn't find any other option or forum online who can assist me on this.

I am using trireme servlet to run the node js script in my application. i have added all the maven dependencies and the deployment description looks as below

<servlet>
   <servlet-name>TriremeServlet</servlet-name>
   <servlet-class>io.apigee.trireme.servlet.TriremeServlet</servlet-class>
   <init-param>
     <param-name>TriremeScript</param-name>
     <param-value>/WEB-INF/node/server.js</param-value>
   </init-param>
   <init-param>
     <param-name>TriremeResponseTimeout</param-name>
     <param-value>5</param-value>
   </init-param>
   <init-param>
     <param-name>TriremeStartupTimeout</param-name>
     <param-value>30</param-value>
   </init-param>
   <init-param>
     <param-name>TriremeSandbox</param-name>
     <param-value>false</param-value>
   </init-param>
 </servlet>
 <servlet-mapping>
   <servlet-name>TriremeServlet</servlet-name>
   <url-pattern>/servlet/*</url-pattern>
 </servlet-mapping>

And my server.js script is below the path /WEB-INF/node/server.js

var fs = require('fs');
var http = require('http');
var path = require('path');
var util = require('util');

....
var server = http.createServer(handleRequest);

server.listen(PORT, function() {
    console.log('Listening on %d', PORT);
});

The above code works fine , i would like to import external libraries to my server.js , added the websocket js files in the same dir /WEB-INF/node/, and tried to import as below. now the script is failing while i try to access the servlet, no errors on log..

var websocket = require('./websocket.js');
Is this the rightway to include the external libraries for the node script that is run by trireme servlet ... appreciate if any feedback

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions