Skip to content

Commit d4cef21

Browse files
committed
Better error message when trying to connect to http port
1 parent d03dec4 commit d4cef21

File tree

5 files changed

+35
-10
lines changed

5 files changed

+35
-10
lines changed

runTests.sh

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ trap finish EXIT
77

88
npm install
99
npm run start-neo4j
10+
sleep 2
1011
npm test

src/v1/internal/connector.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,11 @@ class Connection {
203203
if( buf.hasRemaining() ) {
204204
self._dechunker.write(buf.readSlice( buf.remaining() ));
205205
}
206-
207-
} else {
206+
} else if (proposed == 1213486160) {//server responded 1213486160 == 0x48545450 == "HTTP"
207+
self._handleFatalError(newError("Server responded HTTP. Make sure you are not trying to connect to the http endpoint " +
208+
"(HTTP defaults to port 7474 whereas BOLT defaults to port 7687)"));
209+
}
210+
else {
208211
self._handleFatalError(newError("Unknown Bolt protocol version: " + proposed));
209212
}
210213
};

test/internal/connector.test.js

+21
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,25 @@ describe('connector', function() {
7474
done();
7575
});
7676

77+
it('should provide error message when connecting to http-port', function(done) {
78+
// Given
79+
var conn = connect("bolt://localhost:7474");
80+
81+
// When
82+
conn.initialize( "mydriver/0.0.0", {scheme: "basic", principal: "neo4j", credentials: "neo4j"}, {
83+
onCompleted: function( msg ) {
84+
},
85+
onError: function(err) {
86+
//only node gets the pretty error message
87+
if( require('../../lib/v1/internal/ch-node.js').available ) {
88+
expect(err.message).toBe("Server responded HTTP. Make sure you are not trying to connect to the http endpoint " +
89+
"(HTTP defaults to port 7474 whereas BOLT defaults to port 7687)");
90+
}
91+
done();
92+
}
93+
});
94+
conn.sync();
95+
96+
});
97+
7798
});

test/v1/examples.test.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ describe('examples', function() {
130130
setTimeout(function() {
131131
expect(out[0]).toBe("There were 1 the ones created.");
132132
done();
133-
}, 500)
133+
}, 1000)
134134
});
135135

136136
it('should be able to iterate results', function(done) {
@@ -159,7 +159,7 @@ describe('examples', function() {
159159
setTimeout(function() {
160160
expect(out[0]).toBe("Sword in the stone");
161161
done();
162-
}, 500);
162+
}, 1000);
163163
});
164164

165165
it('should be able to access records', function(done) {
@@ -194,7 +194,7 @@ describe('examples', function() {
194194
setTimeout(function() {
195195
expect(out[0].length).toBe(3);
196196
done();
197-
}, 500)
197+
}, 1000)
198198
});
199199

200200
it('should be able to retain for later processing', function(done) {
@@ -226,7 +226,7 @@ describe('examples', function() {
226226
setTimeout(function() {
227227
expect(out[0]).toBe("Lancelot is a knight of Camelot");
228228
done();
229-
}, 500);
229+
}, 1000);
230230
});
231231

232232
it('should be able to do nested queries', function(done) {
@@ -262,7 +262,7 @@ describe('examples', function() {
262262
setTimeout(function() {
263263
expect(out[0]).toBe("Count is 1");
264264
done();
265-
}, 500);
265+
}, 1000);
266266
});
267267

268268
it('should be able to handle cypher error', function(done) {
@@ -295,7 +295,7 @@ describe('examples', function() {
295295
setTimeout(function() {
296296
expect(out.length).toBe(1);
297297
done();
298-
}, 500);
298+
}, 1000);
299299
});
300300

301301
it('should be able to see notifications', function(done) {
@@ -315,7 +315,7 @@ describe('examples', function() {
315315
setTimeout(function () {
316316
expect(out[0]).toBe("Neo.ClientNotification.Statement.CartesianProductWarning");
317317
done();
318-
}, 500);
318+
}, 1000);
319319
});
320320

321321
it('should document committing a transaction', function() {

test/v1/tck/steps/tlssteps.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = function () {
1515
callback();
1616
});
1717

18-
this.Then(/^sessions should simply work$/, function (callback) {
18+
this.Then(/^sessions should simply work$/, {timeout: 60 * 1000}, function (callback) {
1919
var session = this.driver1.session();
2020
session.run("RETURN 1").then(function (result) {
2121
session.close();

0 commit comments

Comments
 (0)