Category Archives: javascript

Eclipse Paho Javascript Client and browser support

One of my RPi's is configured as webserver (Apache2). On the same RPi runs a MQTT broker (Mosquitto). The website is configured as follows:

[email protected]:/etc/apache2/sites-available# cat 000-default.conf
<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.

        ServerAdmin [email protected]
        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf

#--- PAUL ---

ProxyPreserveHost On

<Location /mqtt>
  ProxyPass "ws://"
  ProxyPassReverse "ws://"

#--- PAUL ---

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
[email protected]:/etc/apache2/sites-available#

And mosquitto is configured as follows:

[email protected]:/etc/mosquitto# cat mosquitto.conf
# Place your local configuration in /etc/mosquitto/conf.d/
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

pid_file /var/run/

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

listener 1883

listener 9001
protocol websockets
[email protected]:/etc/mosquitto#

I've written a very basic webpage to test the functionality (right on the screenshot). Things work fine in MS Edge( bottom left), but fails in some other browsers (Firefox, top left) :


I'm not sure this is a RPi problem or a browser problem, but I need to solve this.

Anyone an idea what could cause this error and how I could solve it?

Thanks in advance,


Joomla! is forcing my concat plus ‘+’ to "%20"

I have this Multi-line string comprised of mostly html, so I decided to use single inverted commas as delimiters.

To keep it succinct, I have removed much of the html from the string to just focus on the error part.

jQuery("#myModal .modal-content").html('<div class="modal-header">' +
      '<h4 class="modal-title" id="myModalLabel">Duplicate Entry Found!</h4></div>' +
      '<a type="button" href="index.php?layout=studentprofile&id=' + studentid +'" target="_blank">View Student Profile</a>' );

What is happening is that the server is urlencoding the code and removing the plus signs + and adding %20in its place.

If I am writing the concatenation like ...studentprofile&id=' + studentid +" (ie. with spaces) the output is'%20%20%20studentid%20%20%20'"

And If I remove all whitespaces from between the strings and the plus sign, like ...studentprofile&id='+studentid+" then the output becomes'%20studentid%20'"

One interesting observation is this is only happening for single inverted commas, and If I just switch the commas it gets back to working correctly.

Other things which I'd like to add is this code used to work flawlessly on previous LAMP installations, but I have recently upgraded the whole stack so don't know if the the webserver or the php language, or even my framework which btw, is Joomla! is introducing this behavior.

One more discovery: This is only happening for the pluses around the studentid variable, rest of all the string with their pluses is working perfect.

OK, I seem to be onto something here, It clearly is Joomla!'s fault now, Found another similar question.

VueRouter doesn’t work properly in history mode – WordPress

I am using Vue project as a Wordpress theme. I've created a simple router but when I enable mode: 'history' I receive blank site. I've tried to configure .htaccess file but with no effects. My project is in VueWP directory in XAMPP htdocs directory. With hash everything works properly. Where is the mistake?

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /VueWP/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /VueWP/index.php [L]
# END WordPress

This is my VueRouter:

import Vue from 'vue';
import Router from 'vue-router';
import Main from '../Components/Main';
import ArticlePage from '../Components/ArticlePage';
import Page from '../Components/Page';


export default new Router({
    mode: 'history',
    routes: [
            path: '/',
            name: 'Main',
            component: Main
            path: '/post/:url',
            name: 'ArticlePage',
            component: ArticlePage
            path: '/page/:url',
            name: 'Page',
            component: Page


Restrict access to files if targeted directly

I have a basic folder structure like this:


I need to be able to block access to the document if someone was to try and get it directly, for example: but allow access if was to be linked from the index.php page.

Would there be a way I can block access like this, or, is there a method of embedding the pdf on the page? I'm open to using PHP or jQuery if it can be done through that as well.

Some of the methods I have tried have been including deny restrictions in the htaccess but then that obviously blocks it altogether.

Thanks in advance.

EU Cookie Law: Block Cookies set by a specific JS File?

i try to block / disable only cookies set by an specific JS File. In my Case the file is.

I don't want to block the hole file, i only want to block cookies that are set by these file.

I test Cookie blocking by unset the header in .httacces, but it didn't work.

<IfModule mod_headers.c>
RequestHeader unset Cookie
Header unset Cookie
Header unset Set-Cookie

I want the file to load normally, but without permission to create cookies.

If Cookies are not allowed in the Browser Software, Adsense is showing ads normaly, but don't load cookies. So why to ask user permission and after that load the adsense script? Wouldn't it be better to block all Cookies generaly or only for that special file. So you don't need a Cookie permission.

Cookie Consent Plugins like these block the hole Script and reenable it after Cookie Permission.

But that is a big Problem, because you lose Money. It makes no sence.

Example (Not a good solution, Because blocked on Pageview and only load after user permission)

<script **type="text/plain"** class="cc-onconsent-inline-advertising">
google_ad_client = "ca-pub-0000000000000000";
google_ad_slot = "0000000000";
google_ad_width = 728;
google_ad_height = 90;
<script type="text/plain" class="cc-onconsent-inline-advertising"

Does anyone have an idea how to block cookies from an JS File with Jquery, Javascript, per PHP or htacess?

Several asynchronous requests from javascript to PHP apache not been asynchronous

This behavior was not present all the time, just come from nothing about a month ago and then disappeared suddenly. The problem is that I can't identify what happened. I have no server debug tool because only take place in production. Roughly 100 ajax request are triggered at the same time using some loop like :

let url = "";

var methods = ["method1", "method2", "method3", "method4"]; //Roughly 100   

$.each(methods, function(index, value) {
    url: url + value,
    method: "POST",
    data: { params: "whatever", otherParams: "whatever" }
  }).done(function(data) {

In server side (apache+php) there are selects, updates and inserts in a relational database. Each request performs an individual thread since apache is hearing.

When I see the network console, all requests starts at the same time (roughly), but here is the problem. The response happen one after the other finish. If request 1 starts at 0 and spend 5 seconds, request 2 starts at 5, and request 3 starts when request 2 was finished. All browser have the same behavior.

The best logic explanation I thought, is that database is blocking some table when performs an update or insert. Some tables are huge and without indexes could spend too much time. Well, staging environment points to the same database and works perfectly asynchronously. So what is going on? It is possible that php or Apache could be stucked in this way for some reason? I thought other crazy idea that is some writing problems with log files in the OS (debian) but I have no idea how that works. So I would be glad if anyone could give me any suggestion. Maybe I could reproduce the problem in a controlled environment and do something to prevent this can happen again.

Some additional information, the API have two clients one in angular the other in javascript+php. It's exactly the same behavior with both clients.

Express not serving static files in public subdir

I'm having several problems trying to serve static files in public subdirectories with Express and Apache. My working path is the following:

  • public
    • css
      • style.css
  • app.js

app. js file:

var express = require('express');
var app = express();
app.use('/', express.static(__dirname + '/public'));

If style. css is inside the public folder everything's fine. If I move it into the css directory (changing the relative html tag), this is the error I get: 404 not found

This is the link in the html file

<link rel="stylesheet" href="css/style.css" type="text/css">

This is my apache server configuration :

<IfModule mod_ssl.c>
    <VirtualHost *:443>

        ServerAdmin [email protected]
        DocumentRoot /var/www/html
        ProxyRequests Off
        ProxyPreserveHost On
        ProxyVia Full
        <Proxy *>
            Require all granted

        <Location /*>
        <Directory "/var/www/">
            AllowOverride None
            Options -Indexes +FollowSymLinks
            Require all granted

Could it be a proxy issue?