Giter VIP home page Giter VIP logo

Comments (3)

kjdelisle avatar kjdelisle commented on September 25, 2024

This should be fixed by the options passthrough changes in 1.x. Needs verification

from loopback-connector-cloudant.

b-admike avatar b-admike commented on September 25, 2024

Verification steps:

  • create a simple http proxy using http-proxy module for local cloudant server:
var http = require('http'),
    httpProxy = require('http-proxy');
httpProxy.createProxyServer({target:'http://localhost:8080'}).listen(7000); 
  • modify datasource to point to proxy:
{
  "cldntlocal": {
    "url": "http://admin:pass@localhost:8080",
    "database": "test-db",
    "name": "cldntlocal",
    "modelIndex": "",
    "requestDefault": {
    "proxy": "http://admin:pass@localhost:7000"
    },
    "connector": "cloudant"
  }
}

result:

| => DEBUG=loopback:connector:cloudant,cloudant,nano node .
  loopback:connector:cloudant Cloudant constructor settings: {"url":"http://admin:pass@localhost:8080","database":"test-db",
"name":"cldntlocal","modelIndex":"","requestDefaults":{"proxy":"http://admin:pass@localhost:7000"},"connector":"cloudant","d
ebug":false} +0ms
  loopback:connector:cloudant Cloudant.prototype.connect +4ms
  cloudant Initialize +0ms { url: 'http://admin:pass@localhost:8080',
  database: 'test-db',
  name: 'cldntlocal',
  modelIndex: '',
  requestDefaults: { proxy: 'http://admin:pass@localhost:7000' },
  connector: 'cloudant',
  debug: false }
  cloudant Create underlying Nano instance, options={"url":"http://admin:pass@localhost:8080","database":"test-db","name":"c
ldntlocal","modelIndex":"","requestDefaults":{"proxy":"http://admin:pass@localhost:7000","agent":{"domain":null,"_events":{}
,"_eventsCount":1,"defaultPort":80,"protocol":"http:","options":{"keepAlive":true,"path":null},"requests":{},"sockets":{},"f
reeSockets":{},"keepAliveMsecs":1000,"keepAlive":true,"maxSockets":null,"maxFreeSockets":256}},"connector":"cloudant","debug
":false} requestDefaults={"proxy":"http://admin:pass@localhost:7000","agent":{"domain":null,"_events":{},"_eventsCount":1,"d
efaultPort":80,"protocol":"http:","options":{"keepAlive":true,"path":null},"requests":{},"sockets":{},"freeSockets":{},"keep
AliveMsecs":1000,"keepAlive":true,"maxSockets":null,"maxFreeSockets":256}} +4ms
  cloudant Automatic ping +2ms
  nano { method: 'GET', headers: { 'content-type': 'application/json', accept: 'application/json' }, uri: 'http://admin:pass
@localhost:8080/_session' } +3ms
Web server listening at: http://0.0.0.0:3000
Browse your REST API at http://0.0.0.0:3000/explorer
  nano { err: null, body: { ok: true, userCtx: { name: 'admin', roles: [Object] }, info: { authentication_db: '_users', auth
entication_handlers: [Object], authenticated: 'default' } }, headers: { date: 'Thu, 01 Jun 2017 19:18:10 GMT', 'content-type
': 'application/json', connection: 'close', 'cache-control': 'must-revalidate', statusCode: 200, uri: 'http://admin:pass@loc
alhost:8080/_session' } } +193ms
  nano { method: 'GET', headers: { 'content-type': 'application/json', accept: 'application/json' }, uri: 'http://admin:pass
@localhost:8080' } +1ms
  nano { err: null, body: { couchdb: 'Welcome', version: '1.0.0.5-local', vendor: { name: 'Cloudant, an IBM Company', versio
n: '1.0.0.5', variant: 'local' }, features: [ 'geo' ] }, headers: { 'x-couchdb-body-time': '0', 'x-couch-request-id': '4080d
dbd02', date: 'Thu, 01 Jun 2017 19:18:10 GMT', 'content-type': 'application/json', connection: 'close', 'cache-control': 'mu
st-revalidate', statusCode: 200, uri: 'http://admin:pass@localhost:8080' } } +16ms

Tried changing the proxy key's port to 7001 to verify that it was indeed using it, and got:

| => DEBUG=loopback:connector:cloudant,cloudant,nano node .
  loopback:connector:cloudant Cloudant constructor settings: {"url":"http://admin:pass@localhost:8080","database":"test-db",
"name":"cldntlocal","modelIndex":"","requestDefaults":{"proxy":"http://admin:pass@localhost:7001"},"connector":"cloudant","d
ebug":false} +0ms
  loopback:connector:cloudant Cloudant.prototype.connect +4ms
  cloudant Initialize +0ms { url: 'http://admin:pass@localhost:8080',
  database: 'test-db',
  name: 'cldntlocal',
  modelIndex: '',
  requestDefaults: { proxy: 'http://admin:pass@localhost:7001' },
  connector: 'cloudant',
  debug: false }
  cloudant Create underlying Nano instance, options={"url":"http://admin:pass@localhost:8080","database":"test-db","name":"c
ldntlocal","modelIndex":"","requestDefaults":{"proxy":"http://admin:pass@localhost:7001","agent":{"domain":null,"_events":{}
,"_eventsCount":1,"defaultPort":80,"protocol":"http:","options":{"keepAlive":true,"path":null},"requests":{},"sockets":{},"f
reeSockets":{},"keepAliveMsecs":1000,"keepAlive":true,"maxSockets":null,"maxFreeSockets":256}},"connector":"cloudant","debug
":false} requestDefaults={"proxy":"http://admin:pass@localhost:7001","agent":{"domain":null,"_events":{},"_eventsCount":1,"d
efaultPort":80,"protocol":"http:","options":{"keepAlive":true,"path":null},"requests":{},"sockets":{},"freeSockets":{},"keep
AliveMsecs":1000,"keepAlive":true,"maxSockets":null,"maxFreeSockets":256}} +6ms
  cloudant Automatic ping +4ms
  nano { method: 'GET', headers: { 'content-type': 'application/json', accept: 'application/json' }, uri: 'http://admin:pass
@localhost:8080/_session' } +4ms
Web server listening at: http://0.0.0.0:3000
Browse your REST API at http://0.0.0.0:3000/explorer
  nano { err: 'socket', body: undefined, headers: { statusCode: 500, uri: 'http://admin:pass@localhost:8080/_session' } } +2
03ms
Connection fails: Error: error happened in your connection
It will be retried for the next request.
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED 127.0.0.1:7001
    at Object.exports._errnoException (util.js:1018:11)
    at exports._exceptionWithHostPort (util.js:1041:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)

from loopback-connector-cloudant.

b-admike avatar b-admike commented on September 25, 2024

connect to https://github.com/strongloop-internal/scrum-apex/issues/240

from loopback-connector-cloudant.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.