Sammy.js working fine one localhost but not when calling from remote computer - jquery-templates

I'm working one SPA with sammy.js and jquery.tmpl.
It's kind of huge project what the company want to work as an SPA.
The issue is that there are few different states for the app (used to be three different pages and now it is all in one, add, edit and add for a non registered client).
When i am developing from my own station (IIS6.1 for windows 7, not VS IIS) and using both localhost of my IP address every thing is working great, but when trying to connect with a domain name (changes the host in my station) or from a remote computer both with ip or domain name i'm getting an 404 from sammy:
body 404 Not Found get /employer/newemployers/index.aspx#/edit/2354478 Error {message: "404 Not Found get /employer/newemployers/index.aspx#/edit/2354478 ", stack: "Error↵ at Object.n.Application.e.extend.error (…oyers/javascript/lib/jquery-1.7.2.min.js:3:17273)"} sammy-0.7.4.min.js:8
My Sammy.js code:
$.sammy('body', function () {
this.get('#/', index);
this.get('#/index', index); //For Non registered Employer
this.get('#/indexPageAdd', indexPageAdd); //For Registered Employer
this.get('#/Edit/:JobID', MainEdit); // For Job Edit
this.get('#/firstStage', firstStage);
this.get('#/secondStage', secondStage);
this.get('#/thirdStage', thirdStage);
}).run('#');
Any one encountered this type or issue? Couldn't find this anywhere..
Thank you

Found the answer,
When calling from my own computer( localhost or ip), Sammy.js is case insensitive, but when trying to use real urls (on my own computer or from remote computer) need to use case sensitive urls, the edit is with capital E and i used lowercase e and didn't notice.... added a record for lowercase and every thing is working great now.
Hope this helped anyone with the same problem

Related

Metatrader 5 Python Socket/Websocket communication 4014 error

I am trying to create a communication interface between a python socket server and a Metatrader 5 Expert Advisor.
I've tried multiple approaches and tutorial's I found online for both sockets and websockets. All of these approaches yield the same problem.
Whenever I start a debug on live/historical data, I get a Socket creation error with code 4014. According to the error codes it is a "Function is not allowed for call" error.
Multiple sources recommended to allow web request from specified URL's. Ive done this as well for 127.0.0.1 and localhost. (Tools > options > Expert Advisors)
Why am I getting a function not allowed for call error, and how can this be fixed?
Expert code:
int socket=SocketCreate();
int OnInit()
{
if(SocketConnect(socket,"127.0.0.1",9090,1000))
{
Print("Connected to "," 127.0.0.1",":",9090);
}
else
{
Print(GetLastError());
}
return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
SocketClose(socket);
}
void OnTick()
{
SocketClose(socket);
}
We had similar issue in the past and was resolved it by adding the hostname/IP to connect to to the list of allowed URLs in Tools->Options->Expert Advisor.
You can also use a MetaApi service to communicate with MetaTrader via developer-friendly SDKs and code your expert advisor in Javascript, Java or Python.
Hope this is useful to some degree.
I faced the same problem.
Works for me: to point exactly '127.0.0.1' (without upper commas) in address input field.
Also, check your firewall settings - it may block your ports.
The best regards.

core_user_create_user and moodle webservice setup not working

I have done everything needed to setup webservices on my moodle 3.11 instance, including roles/capabilities/user. However sending a test request always gives {
"exception": "dml_missing_record_exception",
"errorcode": "invalidrecord",
"message": "Can't find data record in database table external_functions."
}
The URL to access it is of the format https:///moodle/webservice/rest/server.php?wsfunction=core_user_create_user&service=mymoodleusermanage&moodlewsrestformat=json&users[0][username]=ABC&users[0][firstname]=VPTest&users[0][lastname]=None&users[0][email]=mail#xxx.com&users[0][password]=xxxxx&users[0][auth]=manual&wstoken=xxxxxxxxxxxxxx
The service parameter is correctly set to the shortname of the service. Does the service have to be defined anywhere additionally apart from Site Administration->Server->Web Services->External Services->Custom Services
Thanks for any help that can be given
The answer is very simple - you are trying to call a non-existent webservice function (hence the error message about being unable to find the database record for the function in the external_functions database table).
If you look in the Moodle code: https://github.com/moodle/moodle/blob/master/lib/db/services.php#L1717 you will see that the function is called core_user_create_users - with an "s" at the end of it.
If you add that extra "s" into the URL parameters you are using, then it should work.
https:///moodle/webservice/rest/server.php?wsfunction=core_user_create_user&service=mymoodleusermanage&moodlewsrestformat=json&users[0][username]=ABC&users[0][firstname]=VPTest&users[0][lastname]=None&users[0][email]=mail#xxx.com&users[0][password]=xxxxx&users[0][auth]=manual&wstoken=xxxxxxxxxxxxxx
you must change username all character small letter [username]=ABC like this [username]=abc and add s wsfunction=core_user_create_users

IoT Phone recipe connects but not sending data

I am working with Bluemix tutorial recipe "Real Time Data Analysis Using IBM Watson IoT Platform Analytics" presented here:
https://developer.ibm.com/recipes/tutorials/real-time-data-analysis-using-ibm-watson-iot-platform-analytics
I am not seeing the behavior in my Watson IoT dashboard as described; the phone device does connect and register itself but I see no events or data.
In the node server logs a couple things seem concerning:
404 on fetch of util.js; in fact that file is not in my code repository downloaded from the recipe's github.
Three deprecated warnings:
...deprecated multipart: use parser (multiparty, busboy, formidable) npm module instead at node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:56:20
...deprecated limit: Restrict request size at location of read at node_modules/express/node_modules/connect/lib/middleware/multipart.js:86:15
...deprecated methodOverride: use method-override npm module instead at app.js:63:17
The phone device shows some fluttering data values but stays in state "connecting". On the WatsonIoT dashboard it shows registered but "Disconnected".
Is the missing util.js a fatal condition? If not then how next to troubleshoot it as I am new to the whole package?
Solved. The recipe checks for whether it needs to create its cloudant database, unaware that I'm sharing my cloudant service instance with other apps; it finds a db exists, blithely assumes that's the one it needs, and skips the create. Change app.js from:
cloudant.db.list(function(err, all_dbs) {
if (all_dbs.length == 0) {
// first time -- need to create the iotzone-devices database
cloudant.db.create('device_credentials', function()
to e.g.:
cloudant.db.list(function(err, all_dbs) {
if (all_dbs.indexOf(dbName) < 0) {
// first time -- need to create the iotzone-devices database
cloudant.db.create(dbName, function()
[etc...]
With the db in place, WatsonIoT accepts events coming from phone and shows the data as expected.
I found this by following the print statements in log.

Unable to integrate Mongo-Service-Management in CAS 4.2.0

i do not know Java and i'm a newbie with CAS. in the CAS documentations there is an example for MongoDb-Authentication(by example i mean a code sample that i should write inside cas.properties), but for Mongo-Service-Management, there is not any example.
MongoDb-Authentication
cas.authn.mongo.collection.name=users
cas.authn.mongo.db.host=mongodb://user:password#ds061954.somewhere.com:61954/database
cas.authn.mongo.attributes=attribute1,attribute2
cas.authn.mongo.username.attribute=username
cas.authn.mongo.password.attribute=password
i did as such and it's working. (i didn't change the third line though, i don't know what it is.)
but in the Mongo-Service-Management documentation
mongodb.host=mongodb database url
mongodb.port=mongodb database port
mongodb.userId=mongodb userid to bind
mongodb.userPassword=mongodb password to bind
cas.service.registry.mongo.db=Collection name to store service definitions
now here we have cas.service.registry.mongo.db so it's probably the name of our db, but they say it's a Collection name. is that a typo?
should the url include the port, the username and password and the name of the database?
the below code is what i did, and it made the /cas path to return 404 Not Found!
mongodb.host=mongodb://myUserName:myPassword#ds061360.mlab.com:61360/mydb
mongodb.port=61360
mongodb.userId=mydb.myUserName
mongodb.userPassword=myPassword
cas.service.registry.mongo.db=services
mongodb.timeout=5000
as i said this make CAS to be unavailable, so i tried changing the url by removing the username and password, or db name, or the port from the url, none of them works.
the _id of the database user in mlab.com is mydb.myUserName, i changed it to myUserName but this didn't help either. can you provide an example or explain what am i doing wrong?
thank you for any help you are able to provide.

How can I redirect hundreds of hostnames to other hostnames using nginx

I have a system where many (~20k) subdomains use nginx's default_server, which passes the work off to an app.
I also have many (~100) hostnames that need to be redirected to a correct one, that is different for each hostname and that would then redirect to the default_server.
one.example.com -> eleven.example.com
two.example.com -> twelve.domain.com
three.example.com -> wibble.example.com
blah.domain.com -> fifteen.example.com
The redirects are arbitrary, ie there is no pattern to them.
Rather than having to update nginx config to add a new server block whenever a new redirect is needed or updated I'd prefer to use a map file of some sort that nginx can check for redirects.
Sadly having searched about quite a bit I've not found anything like it, all examples I've found use a new server block for each redirecting host or use regexes. I'd prefer to be able to update a map file or database on the fly that nginx can refer to.
My current best option I have is to update the background app to apply the redirects.
I did previously find the map but it wasn't clear that it could be used in this way and none of the examples showed it. Saying that it turned out to be quite easy.
This is what I have that seems to work;
map $host $redirect_host {
hostnames;
one.david.org eleven.david.org;
two.david.org twelve.steve.org;
three.steve.org thirteen.david.org;
four.steve.org fourteen.steve.org;
}
server {
...
if ($redirect_host) {
return 301 $scheme://$redirect_host$request_uri;
}
...
}
It's a shame that this solution requires nginx restart, but it's not a big deal.