WCF Client is Buffering with Streamed Transfer Mode |
It seems that Fiddler may have been introducing its own buffer. With
Fiddler closed, streamed requests were properly handed off to WCF.
On a related note, on it seems that on .NET 4.0 and lower, server-side
buffering for streamed WCF services that are hosted in IIS is unavoidable.
The ASP.NET layer has its own buffering mechanism which waits until the
message is fully received before passing it off to WCF. More details here.
|
How to get latest video streamed to client without using cached copy? |
How are you "streaming" your videos?
If just a download link then perhaps look at Cache busting in ASP.NET,
works fine with ServiceStack for static content, though not tried it with
video. If your returning a stream, perhaps [AddHeader(CacheControl =
"private")]?
Or specify static cache settings in AppHost Configure method:
this.SetConfig(new EndpointHostConfig {
AddMaxAgeForStaticMimeTypes =
new Dictionary<string, TimeSpan>
{
{
"image/jpeg",
TimeSpan.FromDays(7.0)
},
{
"video/mpeg",
|
Why my query doesn't return any results from RavenDB? |
You should check that the index "Raven/DocumentsByEntityName" is defined
for the target database, and that your document has the correct metadata
information.
The metadata should have a line like this:
"Raven-Entity-Name": "CountryRegion"
If this does not help, please also post the ravendb version you are using.
A fiddler trace might also be helpful.
|
Separate internal errors from client errors in custom WCF error handling? |
You should create your own exception class by deriving from
System.Exception and throwing them where your validation fails. In your
IErrorHandler implementation you should check if the exception is yours and
return the Status code you want. For example if MyException was the derived
exception:
public void ProvideFault(Exception error, MessageVersion version, ref
Message fault)
{
MyException me = error as MyException;
if(me != null)
// Set the status code.
}
|
Nutch 2.x No errors, No results neither |
I've now started again with a complete new install of Nutch 2.2.1 -
Hbase-0.94.10 and Solr 4.4.0 as advised vy someone on the mailinglist, due
to that the versions mentioned in the tutorial are years old, and now the
error I'm getting is:
[root@localhost local]# bin/nutch inject /urls/seed.txt
InjectorJob: starting at 2013-08-11 17:59:32
InjectorJob: Injecting urlDir: /urls/seed.txt
InjectorJob: org.apache.gora.util.GoraException:
java.lang.RuntimeException: java.lang.IllegalArgumentException: Not a
host:port pair: �2249@localhost.localdomainlocalhost,45431,1376235201648
|
Asp.NET Web Api: Returning meaningful errors to client? |
400 BadRequest could be used if what you are performing is validation logic
and this validation logic fails for some reason. As far as the additional
information is concerned, you might return some info in the body, for
example as JSON payload:
{
"errorMessage":"Validation failed because user doesn't exist in
alternative database"
}
If on the other hand you are attempting to update an entity that doesn't
exist, you could also send a 404 status code.
|
my pro just shows client side validation errors |
This is the expected behavior for client-side validation: it prevents a
form post on error, because it can very quickly determine that the input
would be invalid.
If you don't want the client-side validation to run, you can disable it and
rely on the corresponding server-side validation to generate the same error
message (assuming you are validating server-side, which you should be).
|
WCF IEnumerable - Streamed Transport Net Tcp |
Here is guidance on transferring large data with streaming.
http://msdn.microsoft.com/en-us/library/ms733742.aspx
At the bottom of the page is a link to some samples, one of which shows
using TCP.
http://msdn.microsoft.com/en-us/library/ms789010.aspx
If this doesn't help, then perhaps you could provide more detail on how it
is failing (error message)?
|
no update on sql server database. No errors just no results |
Your SQL uses @param type in the string.
If you are looking to execute a stored procedure of some sort to negate
most sql injection attacks on a website you might want to consider calling
a stored procedure and adding SqlCommand.Parameter to the
SqlCommand.Parameters Collection.
Otherwise if you want to just execute the sql you should do
string sql = String.Format("UPDATE TABLE set COLUMN = {0} where OTHERCOLUMN
= {1}", varValue, varWhere);
|
Breeze.js - Getting both client and server validation errors onto my entity |
As of Breeze v 1.4.0, your server side validation failures should
automatically be added to the client side validationResults on a per entity
basis, ( in addition to be returned in fail() promise), so you shouldn't
have to do anything else.
Am I missing something?
|
Spring MVC REST Service and Client. I am looking for a better way to deal with errors |
I've used this approach (with JSON/Jackson 2) to good success:
class ErrorHolder {
public String errorMessage;
public ErrorHolder(String errorMessage) {
this.errorMessage = errorMessage;
}
}
@ExceptionHandler
public @ResponseBody ResponseEntity<ErrorHolder>
handle(ResourceNotFoundException e) {
logger.warn("Teh resource was not found", e);
return new ResponseEntity<ErrorHolder>(new ErrorHolder("Uh oh"),
HttpStatus.NOT_FOUND);
}
Works with Spring 3.2.x at least.
|
Android present streamed images |
Updating the UI from a thread other than the UI/main thread will fail as
Android does not allow it. Try using a Handler to post messages back to the
UI thread. You could do something like this.
final Handler h = new Handler();
timer.schedule(new TimerTask() {
public void run() {
if(flag){
h.post(new Runnable() {
public void run() {
Bitmap bmp = null;
Log.i(APPID, "New frame");
try {
bmp = session.getImage();
setImage(bmp);
} catch (Exception e) {
e.printStackTrace();
}
}
} else {
timer.cancel();
}
}
}, 500, 500);
|
Upgrading Google Mobile Ads iOS SDK from 5.0.5 to 6.4.2 results in linker errors |
Maybe you need the -all_load linker flag option too? According to this
article it's obsolete for newer ARM7 targets, but perhaps you have an old
target?
http://vntin.com/feeds.feedburner.com/blogspot/LTiVe
See under this section: "Support for armv7s"
"If you’re targeting the armv7s architecture, you will not need to add
the -all_load linker flag to your projects anymore. "
[Update]
You can try to verify what's in the lib*.a file by using the nm command.
nm -U libGoogleAdMobAds.a | grep kGADAdSizeBanner
Also, clicking on the Log Navigator may provide some additional
information. Select the last icon then your last build in the left nav.
[Update 2]
Someone on this site also complained about a linker problem with the new
API. Might have to make small changes to your code.
h
|
Python, why it is errors 10035 (on server) and 10053 (on client) during using TCP sockets? |
You need to make the child socket blocking. Add this call
"c.setblocking(1)" in the server file (server.py) before you append the new
connection using "connections.append( [c, addr] )" -- like the following
snippet. Looks like the child socket is inheriting the non-blocking option
from the parent server socket. With this change, I was able to run your
code without any errors.
c, addr = server.accept()
print 'Got connection from', addr
c.setblocking(1) # Make it blocking.
connections.append( [c, addr] )
The other alternative would be to catch socket.error in the
recvFromSocket() function in the cs_common.py -- this is because if the
recv() timeouts becuase child sockets are non-blocking, then the recv()
call will return with an error. Since your code is not handling it,
|
How can I import the Google API Objective-C Client Library in to my iOS project without getting errors? |
I'll just quote what @borrrden already wrote. This worked for me.
Make sure that you have the armv7 architecture included in your build
settings under "Architectures"
|
1:1 Alignment of C# Structs with Streamed Delphi Records Possible? |
Alignment is normally used by the compiler as an optimization. Actually
every structure is padded to a multiple of 4 (or 8 I don't remember
exactly).
Update: What I state above about alignment is not accurate. Have a read of
David's answer for details on how aligned records are treated by the
compiler. The Wikipedia article contains a reasonable overview:
http://en.wikipedia.org/wiki/Data_structure_alignment
Anyway, you can use the Pack parameter to specify the alignment. A Pack
value of 1 returns the exact size of the structure.
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
About arrays, it's correct to use:
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
public char[] someCharArray;
Just take care when you convert from structure to byte array that
|
Primefaces Printing Dynamic Streamed Contents |
I used css to hide all other divs during print time and used window.print
command.
Print button
<p:commandButton styleClass="noPrintBlock" ajax="false" value="Print"
onclick="window.print();"
actionListener="#{patientReportController.markAsPrinted()}" />
The component which I want to print.
<p:panel styleClass="printBlock" id="divPrint" >
</p:panel>
Example of a component which I do not want to print
<h:panelGroup styleClass="noPrintBlock">
</h:panelGroup>
CSS
@media print{
.noPrintBlock{
display: none;
}
.printBlock{
height: 100%;
width: 100%;
position: fixed;
top: 0;
left: 0;
margin: 0;
}
}
|
Nginx + emacs - clearing file results in php errors not logging? |
In your FPM Pool Configuration file you can add specific values instead of
editing the php.ini file. Here is what I have in my development:
php_flag[display_errors] = on
php_admin_value[error_log] = /vhosts/example.com/logs/php_error_log
php_admin_flag[log_errors] = on
You would normally add these to the end of the file. You may already see a
few examples pre-packaged there too.
Don't forget to restart FPM after making the changes of course.
|
No errors or results when executing simple query on SQL Server database |
The function getdate() actually returns a datetime. Try converting it to a
date:
AND SessionDate = cast(getdate() as date)
The time component is probably the problem -- preventing a match between
the date and the datetime.
|
Can a WCF service support both Buffered and Streamed transfer modes? |
This is a big question. I understand the problem. The short answer is that
you can't have both streaming and buffering in the same endpoint operation
contract. You can, of course, run 1-many separate endpoints from the same
web service, each with a different port, for instance with some using
buffering and some using streaming.
And, you can have the host set up to stream its responses while the client
(using the same endpoint) can buffer its uploading requests to the host
(and vice versa); that's not a problem. But buffering and streaming
responses from the same host endpoint is not possible.
We've run into the same issue with buffering downloads to the client from
SQL. For a while we went to streaming for downloads, primarily to cure
client device timeouts, but found streaming is memo
|
overriding equals method in java but getting logical errors/unexpected results |
The problem lies in this line:
return s==n;
Here, this will return true if both s and n are false.
You should use s && n to return true only if both s and n are true.
|
Thrift: Python Server, Erlang Client Errors... {thrift_socket_server,244,{child_error,function_clause,[]}} |
Figured it out! I was using TBufferedTransport when I had specified framed
transport in my erlang file. I changed it to TFramedTrasport, recompiled my
thrift files, and everything worked nicely.
|
unable to get this class working in java on client code - no compilation errors but runtime |
In your constructor, you've defined a local variable charCounts:
int[] charCounts= new int[TOTAL_LETTERS];
This shadows the instance variable charCounts, to which I think you meant
to assign it.
Assign it to the instance variable charCounts like this:
charCounts = new int[TOTAL_LETTERS];
This means that, in your code, the instance variable charCounts remains
null until you access and a NullPointerException results.
|
Golang http request results in EOF errors when making multiple requests successively |
I'm going to guess there is no problem with your code. The most likely
cause of your problem is because the server is closing the connection. Rate
limiting is one possible reason for this.
Your test shouldn't be relying on an external service that's very brittle
and not hermetic. Instead you should think about spinning up a test server
locally.
|
Why this action results an empty file on client side? |
It could be because the underlying stream (in your case a MemoryStream) is
not positioned at the beginning when you return it to the client.
Try this just before the return statement:
stream.Position = 0
Also, these lines of code:
writer.Flush();
stream.Flush();
Are not required because the stream is Memory based. You only need those
for disk or network streams where there could be bytes that still require
writing.
|
Throwing an HttpResponseException always results in a StatusCode: 500 response in the client |
I am doing something similar but in the extended ExceptionFilterAttribute.
Not sure if you can do that but thought of sharing the code I currently
use. This is just a sample. as I have lot more to add in this method.
public override void OnException(HttpActionExecutedContext
actionExecutedContext)
{
var actionName =
actionExecutedContext.ActionContext.ActionDescriptor.ActionName;
var controllerName =
actionExecutedContext.ActionContext.ActionDescriptor.ControllerDescriptor.ControllerName;
Logger.LogException(controllerName + ":" + actionName,
actionExecutedContext.Exception);
actionExecutedContext.Response = new
HttpResponseMessage(HttpStatusCode.InternalServerError)
{
ReasonPhras
|
How to zoom and rotate webcam video which is streamed by html5 GetUserMedia API with canvas? |
Update
The reason why this won't work is as follows: when applying CSS transform
on an element it will only be rendered by browser that way. If you try to
use for example the video element and draw its content to canvas the
original content will be drawn excluding the CSS transformation.
So in order for this to work you will have to transform the canvas' context
before drawing the video to it.
For example - for this to be convenient you can use this function will set
all the transforms before the video is drawn:
function updateCanvas() {
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.translate(canvas.width * 0.5, canvas.height * 0.5);
ctx.rotate(rotate * Math.PI / 180);
ctx.scale(zoom, zoom);
ctx.translate(-canvas.wid
|
compareTo() giving conflicting results in a client/server application? |
First, sometimes simple re-arrangement of logical expressions can improve
code readability. For example, second condition is equal to the following
(which looks more simple for me):
( chat_msg.compareTo("Bye!") != 0 && chat_msg.compareTo("Let's
play!") != 0 )
Second, probably your client-server communication protocol adds some white
space character to your string (and this character is not visible when you
print the string). Try using debugger to check actual value of chat_msg.
|
iOS Client connecting to NodeJS socket.io results in Stream end encountered |
Turns out that socket.io has its own authentication protocol and is not
compatible with SocketRocket out of the box. See this SO answer:
How to use SocketRocket with socket.io?
From the answers there, you could take a look at socket.io-objc
|
Modifying a collection while enumerating another one |
Simplest thing to do here is to call coins.RemoveAll(coin =>
coin.delete);. (google List.RemoveAll). That leaves you with a list of
coins with all the "deletes" removed in one statement, no need to worry
about counters or loop variables or temp copies or whatever at all. So
then you can iterate over the remaining coins doing whatever you want.
coins.RemoveAll(coin => coin.delete);
foreach (var coin in coins)
coin.somethingElse();
If you need a faster implementation that only iterates through the list
once, here's what you'd need. Don't use any solution with Remove or
RemoveAt in a loop because those are slow operations, so using them in a
loop will kill performance. The below will just move each "good" coin down
to the index position and then increment index, so at any time
|
Speed of enumerating Hashset |
Yes, there is a huge difference between the two.
Enumerable.ElementAt(int) is an O(n) operation, so your second is has
O(n^2) complexity.
In contrast, enumerating the set through the enumerator is an O(n)
operation.
|
Enumerating combinations by product |
Let's say we want to get a time complexity of O(N * K) where N is the
number of lists and K is the K-th product.
We maintain a pointer at the beginning of each list (for simplicity I call
this P[i] - i'th pointer at list i, and L[i] - the i'th list).
Initially P[i] = 0 for each list (because we start indexing the lists from
0)
Step 1: The first product is L[0][P[1]] * L[1][P[2]] * .. L[N][P[N]].
Step 2: For the next step we are interested in minimizing the next product.
We select j (0<=j<=N) for which L[j][P[j] + 1] is minimum. We
increment P[j] by 1 and then go at Step 1 for computing the next product. I
think it's clear that the next product should be the minimum of all
possibilities.
If you want to count the number of unique products you simply maintain a
counter which you
|
Enumerating class properties |
Non-dynamic classes do not provide enumerable properties or methods.
As stated in the description of the link you provided.
Sets the availability of a dynamic property for loop operations.
I think you might want to refactor your code on this approach.
I have never had to loop over a classes properties like you are doing here.
If you want to track items dynamically you should use an associative array
and track them that way not at the class level like you are doing.
And if you want strong data typing then use a vector.
|
Enumerating monitors on a computer |
In case it is relevant in your case, when using Qt 5.x, you can use the
QGuiApplication::screens() method
(http://qt-project.org/doc/qt-5.1/qtgui/qguiapplication.html#screens) to
enumerate all displays.
Or if it is not relevant, you can always have a look into their source
code, how they enumerate the displays and get all relevant properties (also
regarding mirroring, extended desktops, and so on).
|
What happens if I overwrite an ImmutableHashSet while enumerating it? |
The subscriptions variable is only read at the start of the loop. Remember
that foreach is translating your code into something like:
using (var iterator = subscriptions.GetEnumerator())
{
while (iterator.MoveNext())
{
var s = iterator.Current;
s.Subscriber.OnNext(args);
}
}
So basically, changing the value of the subscriptions variable after you've
called GetEnumerator() won't affect the rest of the behaviour at all -
it'll only affect it next time. (Assuming the relevant memory barriers are
in place, etc.)
|
Trouble enumerating an array |
The fgets function, as stated here, includes the new line (
) character, since it is considered a valid character:
A newline character makes fgets stop reading, but it is considered a
valid character by the function and included in the string copied to str.
This means that you are going to check, for example:
"I left my heart in Harvard Med School"
with
"I left
"
so the match doesn't occur. You could try using gets or replacing the
character with a NUL ():
char search_for[80];
fgets(search_for, 80, stdin);
search_for[strlen(search_for)-1] = '';
|
Why are there missing client-side results when using OData options with Entity Framework DBContext? |
You don't mix and match QueryableAttribute and ODataQueryOptions<T>.
Pick one depending on whether you want manual control over applying the
query options (ODataQueryOptions<T>) or make it happen automatically
(QueryableAttribute).
You have two options,
public IEnumerable<USER> Get(ODataQueryOptions<USER> options)
{
var dbContext = new ATMS.DAL.AtmsContext();
var ret = options.ApplyTo(dbContext.USERS).Cast<USER>();
return ret;
}
or
[Queryable]
public IEnumerable<USER> Get(ODataQueryOptions<USER> options)
{
var dbContext = new ATMS.DAL.AtmsContext();
var ret = dbContext.USERS;
return ret;
}
The reason you are seeing that behavior is that you are applying the query
twice, once using ODataQueryOptions<T>.ApplyTo an
|
RavenDB OrderBy |
If you are using an index you need to set the sortoptions for the Order
property.
From
http://ravendb.net/docs/client-api/querying/static-indexes/customizing-results-order
Numerical values, on the other hand, are stored as text and therefore
require the user to specify explicitly what is the number type used so a
correct sorting mechanism is enforced. This is quite easily done, by
declaring the required sorting setup in SortOptions in the index
definition:
Sort(x => x.Order, SortOptions.Int);
The index outlined above will allow sorting by value on the user's age
(1, 2, 3, 11, etc). If we wouldn't specify this option, it would have been
sorted lexically (1, 11, 2, 3, etc).
The default SortOptions value is String. Appropriate values available for
all numeric types (Byte, Doub
|
Combinatoric Optimization - Enumerating all Subsets that Contain a Given Set |
How about this
# Ruby
require 'set'
s = Set[Set[1, 2, 3, 4], Set[3, 4, 5], Set[1, 2, 3, 7, 8, 9]]
x = Set[1, 3, 4]
class Set
def powerset
inject(Set[Set[]]) do |ps, item|
ps.union ps.map {|e| e.union (Set.new [item])}
end
end
end
pow = s.powerset
pow.select! { |sub|x <= sub.flatten }
p pow
This is O(n * x * 2^n) since we must iterate over the powerset 2^n and
execute n unions (constant time) + x queries to see if X is in the sets.
|
Creating objects and enumerating them during runtime |
You can create a static variable which is increased everytime you create a
list, and use this variable to identify the created list :
static int id = 0;
FunctionThatCreateList {
/* Your creation code */
SetId(id);
id++;
}
That way, everytime you create a list, it's id will be set and you're sure
it'll be unique
|