How to disable console logging for the QuickBlox JS SDK? - quickblox

I am using:
QuickBlox JavaScript SDK - v1.13.1 - 2015-09-18
I have tried the following, as described in the docs:
var QB_CONFIG = {
ssl: true,
debug: {mode: 0},
};
myQB.init(QB_APPLICATION_ID, QB_AUTHORIZATION_KEY, QB_AUTHORIZATION_SECRET, QB_CONFIG);
Also:
var QB_CONFIG = {
ssl: true,
debug: false,
};
Without success:
[QBChat]: Status.CONNECTING
[QBChat]: Chat Protocol - WebSocket ...

Try this
var QB_CONFIG = {
ssl: true,
debug: {
mode: 0,
file: null
}
};

Related

Backend api call not working in Vue(front)

My environment
front - windows, port 3000
backend - linux (ubuntu) in docker container, port 5000
Vue(front) tsconfig.json
export default defineConfig({
plugins: [vue(), vueJsx()],
resolve: {
alias: {
"#": fileURLToPath(new URL("./src", import.meta.url)),
},
},
server: {
host: true,
port: 3000,
proxy: {
"/api": {
target: "http://127.0.0.1:5000",
changeOrigin: true,
secure: false,
rewrite: (path) => path.replace(/^\/api/, ""),
},
},
},
});
front api call code
const response = await axios.post("http://127.0.0.1:5000/users/login?email=" + code);
backend(Nestjs) - main.ts
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors({
origin: 'http://localhost:3000',
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS',
credentials: true,
});
await app.listen(5000);
}
bootstrap();
I expect the api call to go to the backend, localhost:5000
but i get a 404 error
When I tried with postman, I got normal return, but when I sent the request using axios in Vue with the same request, I got 404 not found.
The most incomprehensible thing is that with the current settings, it was normally requested when developing in the past.
I don't know how to fix this
please help a lot
Repositories currently being edited: https://github.com/PracticeofEno/ft_transcendence
thanks
omg... I send POST message..
But api is GET Message

Undefined return when send email using nodemailer package

I am trying to send email with javascript nodemailer package but returning undefined.
Checked following options:
Less app secured is ON
No 2 Factor enabled
enabled https://accounts.google.com/DisplayUnlockCaptcha
Let me know what is missing ?
I have followed all possible noted on this website but could not help me.
Code
async sendEmailWithAttachments(
fromemailid,
toemailid,
fileName,
attachmentsPath
) {
let transporter = nodemailer1.createTransport({
// service: "gmail",
host: "smtp.gmail.com",
port: 587,
secure: false,
debug: true,
auth: {
user: "XXX#gmail.com",
pass: "XXXX",
},
tls: {
rejectUnauthorized: false,
},
logger: true,
});
let mailOptions = {
from: "XXX#gmail.com",
to: "XXX#gmail.com",
subject: "Hello ✔", // Subject line
text: "Hello world?", // plain text body
// attachments: [
// {
// // utf-8 string as an attachment
// filename: fileName,
// path: attachmentsPath,
// },
// ],
};
// send mail with defined transport object
let info = transporter.sendMail(mailOptions, (error, success) => {
if (error) {
console.log(error);
}
});
console.log("================= Mail sent ===============", info);
}
Here info object shows undefinded
Here Console log:
[0-0] [2022-05-31 05:52:03] DEBUG Sending mail using SMTP/6.7.5[client:6.7.5]
[0-0] ================= Mail sent =============== **undefined**
[0-0] 2022-05-31T05:52:03.787Z DEBUG #wdio/utils:shim: Finished to run "afterTest" hook in 0ms
[0-0] 2022-05-31T05:52:03.796Z INFO webdriver: COMMAND deleteSession()
[0-0] 2022-05-31T05:52:03.796Z INFO webdriver: [DELETE] http://localhost:9515/session/cfa202e5063720bed6ff7fa47b29f96d
[0-0] [2022-05-31 05:52:03] DEBUG [5nz3hZn0uA] Resolved smtp.gmail.com as XX.XXX.XXX.XXX [cache miss]
[0-0] [2022-05-31 05:52:03] INFO [5nz3hZn0uA] Connection established to XX.XXX.XXX.XXX:587```

Saving an express-session in socket.io

I can not understand why my sessions do not want to be saved.
Each time I connect, I get a new session id, but if I just go (through the browser) to tessocket.local, the session is saved and already when called through the socket, it is normally determined. That's actually the question - how to defeat it?
Forcing the session to be saved after io.on("connection" doesn't help.
If you remove transports: ["websocket"] - polling starts working, but then the session is not defined at all through the socket.
client.js
const socketOptions = {
"force new connection" : true,
"reconnectionAttempts": "Infinity",
"timeout" : 10000,
"transports" : ["websocket"]
};
// #ts-ignore
socket = io('https://tessocket.local',socketOptions)
// #ts-ignore
socket.onAny((event, ...args) => {
console.log(event, args);
});
return socket
server.js
const app = require('express')(),
http = require('http'),
https = require('https'),
// http = require("http"),
fs = require( "fs" ),
path = require("path"),
eSession = require("express-session"),
MongoDBStore = require('express-mongodb-session')(eSession),
store = new MongoDBStore({
uri: 'mongodb://admin:admin#localhost:27017/tmp?authSource=admin',
collection: 'sessions'
});
options = {
key: fs.readFileSync(path.resolve(__dirname, "../minica/test.local/key.pem")),
cert: fs.readFileSync(path.resolve(__dirname, "../minica/test.local/cert.pem")),
},
server = https.createServer(options, app)
const io = require("socket.io")(server, {
cors: "http://test.local:3000",
transports: ["websocket"]
}),
session = eSession({
secret: "my-secret",
resave: true,
saveUninitialized: true,
store,
cookie: {
httpOnly: false, // key
maxAge: null,
path: "/",
secure: true,
sameSite: 'none'
},
}),
sharedsession = require("express-socket.io-session");
// Attach session
app.use(session);
// Share session with io sockets
io.use(sharedsession(session));
io.on("connection", function(socket) {
// Accept a login event with user's data
console.log(socket.handshake.session.id)
socket.on("login", function(userdata) {
socket.handshake.session.userdata = userdata;
socket.handshake.session.save();
});
socket.on("logout", function(userdata) {
if (socket.handshake.session.userdata) {
delete socket.handshake.session.userdata;
socket.handshake.session.save();
}
});
});
server.listen(443);
socket.io#4.4.1
express#4

Peerjs keeps loosing connection and user id is lost

I have made an application following a tutorial using peerjs. Everything seems to be working fine except when I make a connection for a video call where I am using peerjs. I have made my own peerjs server which I am running on localhost (right now for testing). Here is the code for the peer server:
const express = require('express');
const path = require('path');
const http = require('http');
const cors = require('cors');
const errorhandler = require('errorhandler');
var ExpressPeerServer = require('peer').ExpressPeerServer;
var options = {
debug: true,
key: 'copycat'
};
var app = express();
var server = http.createServer(app);
var port = process.env.PORT || '3001';
app.set('port', port);
app.use(cors());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/peerjs', ExpressPeerServer(server, options));
app.use(errorhandler());
process.on('uncaughtException', function(exc) {
console.error(exc);
});
server.listen(port);
As you can see I am running the app on port 3001. Now following is the script for peerjs connection for a video call:
// PeerJS
// Compatibility shim
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
// PeerJS object
var peer = new Peer(username + roomId, {
host: 'localhost',
path: '/peerjs',
port: 443,
secure: true,
key: 'copycat',
debug: true
});
peer.on('open', function () {
$('#my-id').text(peer.id);
});
// Receiving a call
peer.on('call', function (call) {
// Answer the call automatically (instead of prompting user) for demo purposes
call.answer(window.localStream);
step3(call);
});
peer.on('error', function (err) {
alert(err.message);
// Return to step 2 if error occurs
step2();
});
// Click handlers setup
$(function () {
$('#make-call').click(function () {
// Initiate a call!
var call = peer.call($('#callto-id').val(), window.localStream);
step3(call);
});
$('#end-call').click(function () {
window.existingCall.close();
step2();
});
step1();
});
function step1() {
// Get audio/video stream
navigator.getUserMedia({ audio: true, video: true }, function (stream) {
// Set your video displays
$('#my-video').prop('src', URL.createObjectURL(stream));
window.localStream = stream;
step2();
}, function () { $('#step1-error').show(); });
}
function step2() {
$('#step1, #step3').hide();
$('#step2').show();
}
function step3(call) {
// Hang up on an existing call if present
if (window.existingCall) {
window.existingCall.close();
}
// Wait for stream on the call, then set peer video display
call.on('stream', function (stream) {
$('#second-video').prop('src', URL.createObjectURL(stream));
});
// UI stuff
window.existingCall = call;
$('#second-id').text(call.peer);
call.on('close', step2);
$('#step1, #step2').hide();
$('#step3').show();
}
This is pretty much the example code from peerjs example file on github. What I am confused about is the port value. Inside the options in the above script its port 443. I get the following error in chrome when I try to make a video call:
peer.js:1492 WebSocket connection to 'wss://localhost/peerjs/peerjs?key=peerjs&id=User80925be509c6c606fa21409858f5&token=zz69b3ccyk' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
Socket._startWebSocket # peer.js:1492
Socket.start # peer.js:1481
Peer._initialize # peer.js:1058
Peer # peer.js:962
(anonymous) # 5be509c6c606fa21409858f5:183
peer.js:1741 PeerJS: Socket closed.
peer.js:1741 PeerJS: ERROR Error: Lost connection to server.
peer.js:1555 POST https://localhost/peerjs/peerjs/User80925be509c6c606fa21409858f5/zz69b3ccyk/id?i=0 net::ERR_CONNECTION_REFUSED
Socket._startXhrStream # peer.js:1555
Socket.start # peer.js:1480
Peer._initialize # peer.js:1058
Peer # peer.js:962
(anonymous) # 5be509c6c606fa21409858f5:183
peer.js:1741 PeerJS: ERROR Error: Lost connection to server.
Please advise what am I doing wrong???
If you are using at your local end then use your localport i.e. 3001 else use 443
make object like this
var peer = new Peer(undefined, {
host: 'localhost',
path: '/peerjs',
port: 3001,
secure: true,
key: 'copycat',
debug: true
});

Socket.io - ReferenceError: io is not defined on Grunt-express

I've got problem with socket.io on grunt-express.
I've tried many ways but it's still not working. I didn't have this problem when I ran express with socket.io without grunt. I had the same code in server.js and index.html.
There is an error in the browser console:
GET http://localhost:9000/socket.io/socket.io.js
angular.js:11655 ReferenceError: io is not defined
at new <anonymous> (http://localhost:9000/scripts/controller.js:13:18)
at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:4203:17)
at $get.extend.instance (http://localhost:9000/bower_components/angular/angular.js:8493:21)
at http://localhost:9000/bower_components/angular/angular.js:7739:13
at forEach (http://localhost:9000/bower_components/angular/angular.js:331:20)
at nodeLinkFn (http://localhost:9000/bower_components/angular/angular.js:7738:11)
at compositeLinkFn (http://localhost:9000/bower_components/angular/angular.js:7117:13)
at publicLinkFn (http://localhost:9000/bower_components/angular/angular.js:6996:30)
at compile (http://localhost:9000/bower_components/angular-ui-router/release/angular-ui-router.js:3905:9)
at invokeLinkFn (http://localhost:9000/bower_components/angular/angular.js:8258:9) <div class="pages ng-scope" ui-view="">
Here is my code from server.js:
var express = require('express');
var path = require('path');
var http = require('http');
var io = require('socket.io')(http);
var app = express();
app.use(express.static(path.join(__dirname, './app/')));
in index.html:
<script src="/socket.io/socket.io.js"></script>
scripts/controller.js
app.factory('socket', function() {
var socket = io();
return socket;
})
app.controller('loginCtrl', function($scope, socket) {
...
});
and my Gruntfile.js:
connect: {
options: {
port: 9000,
socketio: true,
open: true,
livereload: 35729,
// Change this to '0.0.0.0' to access the server from outside
hostname: 'localhost'
},
...
express: {
options: {
port: 3000,
delay: 500,
background: true
},
dev: {
options: {
script: '<%= config.app %>/server/server.js'
}
}
},