I'm writing a Perl server for my church using Mojolicious::Lite that will run on a Raspberry Pi 2. I wrote the software on my laptop running Linux Mint and have tested it along the way on the Raspberry Pi. My most recent addition was a simple login screen that stores an authentication in a session. It works fine when running on the laptop, and can be accessed from Firefox and Chrome on Linux and Chrome and Safari from my iPhone. When the same code runs on the Raspberry, it works for everything but Safari on the iPhone. The Safari shows a 0 byte cookie in the Settings->Safari->Advanced->Website Data. The same version of Mojolicious is running on both the laptop and the Raspberry (6.14). I get the same results with the simple example in the Mojolicious::Guides::Tutorial that increments a counter. When using the Safari iPhone browser to look at the counter on the laptop, the counter increments and the stored cookie is .2kb, but when looking at the same code running on the Raspberry, the counter never increments and the cookie is 0 bytes. Here is the sample code:
use Mojolicious::Lite;
# Access session data in action and template
get '/counter' => sub {
my $c = shift;
$c->session->{counter}++;
};
app->start;
__DATA__
## counter.html.ep
Counter: <%= session 'counter' %>
On my laptop I am running Linux Mint with Perl 5.18.2 and Mojolicious 6.14. On the Raspberry, I am running Raspbian Wheezy, with Perl 5.14.2 (the latest available with the default archives when doing apt-get) and Mojolicious 6.14. Any help you could offer in getting this working would be greatly appreciated.
Thanks!
Garry
Well, I've found the problem and resolved it. It wasn't the different versions of Mojolicious, the different versions of Perl, different modules or different libraries. The problem was that, when I set up the Raspberry last month, I didn't take the time to set up ntpd. So when the power went out last week, the time didn't reset properly when the Raspberry started back up. After trying many, many things, I happened to notice this morning that the time reported was off by about 2 1/2 hours. Resetting the clock brought the world back to normal. Apparently, the Safari browser was looking at the incoming cookie, seeing that its expiration date (now + 1 hr) was in the past, and since it was expired, not storing it. Anyway, that's what it took to resolve the problem, and I feel pretty foolish for not catching it sooner. Thanks for your help.
Related
I have been using a number of Raspberry Pi 4 devices running Raspbian Buster with the standard packaged version of Supercollider (3.10.0) sound synth for some time. Last week, an 'apt update & upgrade' stopped them all from working. This only affected the Raspberry Pi OS as the other versions on ubuntu (amd/intel) all continued to function. Installing ubuntu on the RPi4 was partially successful, but the sound output was badly distorted.
I could not find out whether it was a problem with Supercollider, Jackd or an updated OS file that either one of Supercollider or Jackd rely on. I tried a weeks' worth of fixes and solutions found elsewhere on the interweb, none worked, although error messages were similar.
I have finally got myself back to square one by reimaging with 2020-08-20-raspios-buster-armhf-full.img and NOT updating anything with 'apt update/upgrade'.
If anyone is interested in this issue being resolved and are able to provide me some useful tips on upgrading a bit at a time or comparing the files in two debian images, please let me know. Otherwise I will just continue with this old OS version and hope someone else fixes this issue before I have to apt update. Anyone else with this issue, I hope that knowing that 2020-08-20-raspios-buster is a potential solution will be of use to you.
I have tried so, so many different solutions and absolutely nothing worked, so no more suggestions like that please.
Here are the consistent error messages for users seraching:-
JackPosixProcessSync::LockedTimedWait error usec = 5000000 err = Connection timed out
Driver is not running
Cannot read socket fd = 5 err = Success
Cannot create new client
CheckRes error
JackSocketClientChannel read fail
Cannot open SuperCollider client
JackShmReadWritePtr1::~JackShmReadWritePtr1 - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
terminate called without an active exception
could not initialize audio.
ALSA: poll time out, polled for 34828070 usecs
JackAudioDriver::ProcessAsync: read error, stopping...
I'm extremely new to Raspberry pi and I was looking to figure out how to launch a discord bot on startup when the pi first turns on. I looked this issue up on both this form and other places on the internet and found nothing or confusing results I don't really understand. I'm using Crontab -e to run my python3 program but regardless the file will not run.
This is what I have typed right now: .#reboot sleep 60 && python3 /home/pi/Desktop/MiniWeston/Mini_Weston2.py &
Other forms and videos tell me that this line of code should work but nothing has worked. If you're are wondering, I added the 'sleep 60' because some users said the problem was caused by the pi not connecting to the internet in time and in turn not connecting the bot successfully.
Help would be appreciated, I'm really lost.
I had encoured the same issue crontab just wouldn't run my discord.py bot so what i did was to add it as a service, which you can learn more from here.
I'm currently running Robotframework in Eclipse on Windows 10 OS. I'm using an external python library that allows students and teachers to use this extracted library to connect to our hardware devices. I'm automating the extractions from the main site package made by our developers. If more than one device is plugged into the USB ports on the PC, then the code does the following:
x = input("Select one device:")
selected = int(x)
This causes a terminal prompt so the user has to type in a 0, or 1 for example, then hit the ENTER key. User response will allow the code to further process a connect to the selected device. Note, this prompt is not a GUI. So when I run Robotframework, it will execute the steps up to the point where it's prompting.
It seems like this should be pretty easy, but I can't seem to figure it out. Since you're inside a piece of code that's waiting for input, how do you make RobotFramework do something with it?
Edit: It occurs to me that maybe there's a way to execute a delayed Robotframework step that starts an external python command after a specified time, to throw a '0' and a RETURN key response. I had a python file made from an import of pynput.py library which appears to work from the command line execution (prints a 0, or a 1, and a return line feed). There's gotta be an easier way I'd think, but I don't know what it is.
Edit: Can I run a keyword from a listener that watches for the command prompt and the keyword runs another python file to feed the prompt? If I get this to work, then all I have to do is leave the devices on the USB port (or hub for that matter), and select the devices I want to do further testing on. Our devices are supported Blooth tooth as well but I need to run both USB and BLE tests to verify our Python extractions the teachers and students can use.
Edit: The other option is to use a software programmable hub and select the USB with a specific device on it, but I'm trying to avoid that.
OK, I solved it using Robotframework background process. I wrote a small python file that gets executed from the process. It has a 5 second timer (more than I need) and then Robotframework runs the next Test Case step. The Python file then does some keyboard presses, selecting the port and an ENTER key which goes out to the console (feeding the input prompt). It connects the sensor.
So in my Robotframework Test Case I do the following:
*** Test Case ***
smoke_test
Start process . Python . usbportselect
open usb
The Python program called from the process looks like this:
import time
import pynput
from pynput.keyboard import Key, Controller
keyboard = Controller()
def choose_usb(portvalue)
keyboard.press(portvalue)
keyboard.release(portvalue)
keyboard.press(Key.enter)
keyboard.release(Key.enter)
time.sleep(5)
choose_usb('0')
Note: I'm pretty sure this won't fix all the problems with using processes, but it's at least a start and a way to feed input to a prompt resulted from a future Test Case step
I'm setting up some new VNC servers. I already have this setup working with CentOS 6.3, although I'm not certain that this difference is the real problem.
One of the window managers I'm making available is fluxbox, but when I start it, I always get the following: Error: Couldn't connect to XServer. Here's my setup:
fluxbox: fluxbox-1.1.1-5.el6.x86_64
vnc : tigervnc-server-1.1.0-5.el6_4.1.x86_64
OS : CentOS 6.4
Note that I can start other window managers: Gnome, KDE, openbox, xfce4, etc.
I gutted my ~/.vnc/xstartup script so it only loads an xterm. Then, I tried running startfluxbox &, but still got the error. Obviously, VNC is working, since my xterm opened up OK. I can start firefox, another xterm or other app requiring X, and even fluxbox comes up, but it is worthless in its current state, since it is not connected to the X session.
What is fluxbox looking for? Are there some log files I can look at to give me some clues?
Thanks,
David
CentOS/RHEL 6.4 and up have upgraded libX11 and Xorg.
The $DISPLAY var handling has changed in libX11.
This one in particular is described in this git commit:
http://cgit.freedesktop.org/xorg/lib/libX11/commit/?id=f92e754297ec5fdb81068b56a4435026666224fa
we run our fluxbox with this script in our vnc configs now:
/usr/bin/fluxbox -display "$DISPLAY.0"
OK, I think I've figured out the problem, so I'm answering my own question.
In VNC, I usually specify a display number. (Note, however, that the problem occurs even if vncserver uses the first available display number.) So, I start the vncserver as:
vncserver :17
This should create an X session where my $DISPLAY is set to :17.0, but in CentOS 6.4, the $DISPLAY is set to :17 instead. Apparently, unlike other window managers, fluxbox is unable to handle this inaccuracy. The problem, then, was that fluxbox was trying to connect to :17 and was unable to do so.
My solution, as suggested by someone answering a different problem, was to set $DISPLAY as part of the invocation of fluxbox. So, in my ~/.vnc/xstartup file, I have:
DISPLAY=$DISPLAY.0 startfluxbox &
Note that this may not work for other releases of CentOS, so you might wish to test the release of the box you are using before adding the DISPLAY=... setting to the command.
Is there a way to slow down the internet connection to the iPhone Simulator, so as to mimic how the App might react when you are in a slow spot on the cellular network?
How to install Apple’s Network Link Conditioner
These instructions current as of October 2019.
Warning: If you just upgraded to new version of macOS, make sure you install the very latest Network Conditioner (in Additional Tools for Xcode) or it may silently fail; that is, you will turn it on but it won’t throttle anything or drop any packets.
Update: As of Xcode 11, there may be an even simpler way to simulate network conditions on tethered devices; see this blog post. For how to affect simulated devices, continue below, as before.
Install Xcode if you don’t have it.
Open Xcode and go to Xcode › Open Developer Tool › More Developer Tools…
Download Additional Tools for Xcode (matching your current Xcode version)
Open the downloaded disk image and double-click the Network Link Conditioner .prefpane under “Hardware” to install it.
There we go!
Be sure to turn it on. You need to select a profile and enable the network conditioner.
Caveat
This won't affect localhost, so be sure to use a staging server or co-worker's computer to simulate slow network connections to an API you’re running yourself. You may find https://ngrok.com/ helpful in this regard.
"There's an app for that!" ;) Apple provides "Network Link Conditioner" preference pane that does the job quite well.
for Xcode versions prior to 4.3, the pane installer can be found in your Developer folder, e.g. "/Developer/Applications/Utilities/Network Link Conditioner", after installation, if daemon fails to start and you don't want to reboot your machine, just use sudo launchctl load /system/library/launchdaemons/com.apple.networklinkconditioner.plist
if you are already done with Developer folder, you can install the pane as a part of "Hardware IO Tools for Xcode" package available via Mac Dev Center additional downloads section.
Link to download page (you must log in with your Apple ID): https://developer.apple.com/downloads/index.action
(credits to #nverinaud)
An app called SpeedLimit
https://github.com/mschrag/speedlimit
Works great.
chris.
It also worth mentioning that Xcode also has a built in way for devices, not simulator.
Just go 'Devices and Simulator' (cmmd+shift+2)
Select your device
Scroll down til you find 'Device Conditions'
Set your desired profile
Hit Start
To have this working you need to install 'Network Link Conditioner' on your Mac. See steps mention in Alan's answer
I would argue that a slow connection isn't enough to simulate real-work mobile data network behaviour - since there is also much more packet loss, higher latencies and more dropped connections too.
Here is a handy script I found to configure the firewall to emulate these parameters:
http://pmilosev-notes.blogspot.com/2011/02/ios-simulator-testing-over-different.html
#!/bin/sh
if [ "$#" -ne "3" ]
then
echo "Usage:\n$0 <bandwidth in kpbs> <delay in ms> <packet loss ratio>";
exit 1
fi
BW=$1
DELAY=$2
PLR=$3
sudo ipfw pipe 1 config bw ${BW}Kbit/s delay $DELAY plr $PLR
sudo ipfw add 1 pipe 1 all from me to not me
sudo ipfw add 2 pipe 1 all from not me to me
echo "RETURN to stop connection noise"
read
sudo ipfw delete 1
sudo ipfw delete 2
exit 0
Some suggested values you can use:
Scenario
Bw (Kbit)
delay (ms)
pr (ratio)
2.5G mobile
(GPRS)
50
200
3G mobile
1000
200
0.2
VSAT
5000
500
0.2
Busy LAN on VSAT
300
500
0.4
There isn't a direct way to emulate a slow connection, unlike, say, the nice network connection emulator that blackberry developers enjoy. However, since your simulator's connection goes through your computer - you can simply focus on slowing down your computer's connection.
You'll want to achieve two things (depending upon your circumstances):
throttle your bandwidth
increase your latency
Maybe this will point you in right direction:
http://www.macosxhints.com/article.php?story=20080119112509736
There are some good open source solutions, too, but I so can't remember their names.
This question might help: How to throttle network traffic for environment simulation?
You can do it in really device through Xcode(14) settings
Debug -> Induce Device conditions -> Network Link -> select the Network you want